diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/audio/rocker_codec.c | 30 | ||||
-rw-r--r-- | firmware/drivers/audio/xduoolinux_codec.c | 78 |
2 files changed, 77 insertions, 31 deletions
diff --git a/firmware/drivers/audio/rocker_codec.c b/firmware/drivers/audio/rocker_codec.c index 23541a4ddb..5404ff9561 100644 --- a/firmware/drivers/audio/rocker_codec.c +++ b/firmware/drivers/audio/rocker_codec.c | |||
@@ -29,6 +29,9 @@ | |||
29 | 29 | ||
30 | static int fd_hw; | 30 | static int fd_hw; |
31 | 31 | ||
32 | static long int vol_l_hw = 255; | ||
33 | static long int vol_r_hw = 255; | ||
34 | |||
32 | static void hw_open(void) | 35 | static void hw_open(void) |
33 | { | 36 | { |
34 | fd_hw = open("/dev/snd/controlC0", O_RDWR); | 37 | fd_hw = open("/dev/snd/controlC0", O_RDWR); |
@@ -41,19 +44,32 @@ static void hw_close(void) | |||
41 | close(fd_hw); | 44 | close(fd_hw); |
42 | } | 45 | } |
43 | 46 | ||
44 | void audiohw_preinit(void) | 47 | void audiohw_mute(int mute) |
45 | { | 48 | { |
46 | long int hp = 2; | 49 | if(mute) |
50 | { | ||
51 | long int ps0 = 0; | ||
52 | alsa_controls_set_ints("Output Port Switch", 1, &ps0); | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | long int ps2 = 2; | ||
57 | alsa_controls_set_ints("Output Port Switch", 1, &ps2); | ||
58 | } | ||
59 | } | ||
47 | 60 | ||
61 | void audiohw_preinit(void) | ||
62 | { | ||
48 | alsa_controls_init(); | 63 | alsa_controls_init(); |
49 | hw_open(); | 64 | hw_open(); |
50 | |||
51 | /* Output port switch set to Headphones */ | ||
52 | alsa_controls_set_ints("Output Port Switch", 1, &hp); | ||
53 | } | 65 | } |
54 | 66 | ||
55 | void audiohw_postinit(void) | 67 | void audiohw_postinit(void) |
56 | { | 68 | { |
69 | long int hp = 2; | ||
70 | |||
71 | /* Output port switch set to Headphones */ | ||
72 | alsa_controls_set_ints("Output Port Switch", 1, &hp); | ||
57 | } | 73 | } |
58 | 74 | ||
59 | void audiohw_close(void) | 75 | void audiohw_close(void) |
@@ -69,8 +85,8 @@ void audiohw_set_frequency(int fsel) | |||
69 | 85 | ||
70 | void audiohw_set_volume(int vol_l, int vol_r) | 86 | void audiohw_set_volume(int vol_l, int vol_r) |
71 | { | 87 | { |
72 | long int vol_l_hw = -vol_l/5; | 88 | vol_l_hw = -vol_l/5; |
73 | long int vol_r_hw = -vol_r/5; | 89 | vol_r_hw = -vol_r/5; |
74 | 90 | ||
75 | alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw); | 91 | alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw); |
76 | alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw); | 92 | alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw); |
diff --git a/firmware/drivers/audio/xduoolinux_codec.c b/firmware/drivers/audio/xduoolinux_codec.c index 5db4902e5f..eedde1d667 100644 --- a/firmware/drivers/audio/xduoolinux_codec.c +++ b/firmware/drivers/audio/xduoolinux_codec.c | |||
@@ -29,9 +29,14 @@ | |||
29 | #include "panic.h" | 29 | #include "panic.h" |
30 | #include "sysfs.h" | 30 | #include "sysfs.h" |
31 | #include "alsa-controls.h" | 31 | #include "alsa-controls.h" |
32 | #include "pcm-alsa.h" | ||
32 | 33 | ||
33 | static int fd_hw; | 34 | static int fd_hw; |
34 | 35 | ||
36 | static long int vol_l_hw = 255; | ||
37 | static long int vol_r_hw = 255; | ||
38 | static long int last_ps = 0; | ||
39 | |||
35 | static void hw_open(void) | 40 | static void hw_open(void) |
36 | { | 41 | { |
37 | fd_hw = open("/dev/snd/controlC0", O_RDWR); | 42 | fd_hw = open("/dev/snd/controlC0", O_RDWR); |
@@ -44,44 +49,69 @@ static void hw_close(void) | |||
44 | close(fd_hw); | 49 | close(fd_hw); |
45 | } | 50 | } |
46 | 51 | ||
47 | void audiohw_preinit(void) | 52 | void audiohw_mute(int mute) |
48 | { | 53 | { |
49 | alsa_controls_init(); | 54 | if(mute) |
50 | hw_open(); | 55 | { |
56 | #if defined(XDUOO_X3II) | ||
57 | alsa_controls_set_bool("AK4490 Soft Mute", true); | ||
58 | #endif | ||
59 | #if defined(XDUOO_X20) | ||
60 | long int ps0 = (last_ps > 1) ? 1 : 2; | ||
61 | alsa_controls_set_ints("Output Port Switch", 1, &ps0); | ||
62 | #endif | ||
63 | } | ||
64 | else | ||
65 | { | ||
66 | #if defined(XDUOO_X3II) | ||
67 | alsa_controls_set_bool("AK4490 Soft Mute", false); | ||
68 | #endif | ||
69 | #if defined(XDUOO_X20) | ||
70 | alsa_controls_set_ints("Output Port Switch", 1, &last_ps); | ||
71 | #endif | ||
72 | } | ||
51 | } | 73 | } |
52 | 74 | ||
53 | void audiohw_postinit(void) | 75 | void audiohw_set_output(void) |
54 | { | 76 | { |
55 | long int ps = 2; // headset | 77 | long int ps = 2; // headset |
78 | |||
56 | int status = 0; | 79 | int status = 0; |
57 | 80 | ||
58 | const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; | 81 | const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; |
59 | const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; | 82 | const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; |
60 | #ifdef XDUOO_X20 | 83 | #if defined(XDUOO_X20) |
61 | const char * const sysfs_bal_switch = "/sys/class/switch/balance/state"; | 84 | const char * const sysfs_bal_switch = "/sys/class/switch/balance/state"; |
62 | #endif | 85 | #endif |
63 | 86 | ||
64 | #if defined(XDUOO_X3II) | ||
65 | alsa_controls_set_bool("AK4490 Soft Mute", true); | ||
66 | #endif | ||
67 | |||
68 | sysfs_get_int(sysfs_lo_switch, &status); | 87 | sysfs_get_int(sysfs_lo_switch, &status); |
69 | if (status) ps = 1; // lineout | 88 | if (status) ps = 1; // lineout |
70 | 89 | ||
71 | sysfs_get_int(sysfs_hs_switch, &status); | 90 | sysfs_get_int(sysfs_hs_switch, &status); |
72 | if (status) ps = 2; // headset | 91 | if (status) ps = 2; // headset |
73 | 92 | ||
74 | #ifdef XDUOO_X20 | 93 | #if defined(XDUOO_X20) |
75 | sysfs_get_int(sysfs_bal_switch, &status); | 94 | sysfs_get_int(sysfs_bal_switch, &status); |
76 | if (status) ps = 3; // balance | 95 | if (status) ps = 3; // balance |
77 | #endif | 96 | #endif |
78 | 97 | ||
79 | /* Output port switch */ | 98 | if (last_ps != ps) |
80 | alsa_controls_set_ints("Output Port Switch", 1, &ps); | 99 | { |
100 | /* Output port switch */ | ||
101 | last_ps = ps; | ||
102 | alsa_controls_set_ints("Output Port Switch", 1, &last_ps); | ||
103 | } | ||
104 | } | ||
81 | 105 | ||
82 | #if defined(XDUOO_X3II) | 106 | void audiohw_preinit(void) |
83 | alsa_controls_set_bool("AK4490 Soft Mute", false); | 107 | { |
84 | #endif | 108 | alsa_controls_init(); |
109 | hw_open(); | ||
110 | } | ||
111 | |||
112 | void audiohw_postinit(void) | ||
113 | { | ||
114 | audiohw_set_output(); | ||
85 | } | 115 | } |
86 | 116 | ||
87 | void audiohw_close(void) | 117 | void audiohw_close(void) |
@@ -97,24 +127,24 @@ void audiohw_set_frequency(int fsel) | |||
97 | 127 | ||
98 | void audiohw_set_volume(int vol_l, int vol_r) | 128 | void audiohw_set_volume(int vol_l, int vol_r) |
99 | { | 129 | { |
100 | long int vol_l_hw = -vol_l/5; | 130 | vol_l_hw = -vol_l/5; |
101 | long int vol_r_hw = -vol_r/5; | 131 | vol_r_hw = -vol_r/5; |
102 | 132 | ||
103 | alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw); | 133 | alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw); |
104 | alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw); | 134 | alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw); |
105 | } | 135 | } |
106 | 136 | ||
107 | void audiohw_set_filter_roll_off(int value) | 137 | void audiohw_set_filter_roll_off(int value) |
108 | { | 138 | { |
109 | /* 0 = fast (sharp); | 139 | /* 0 = Sharp; |
110 | 1 = slow; | 140 | 1 = Slow; |
111 | 2 = fast2 | 141 | 2 = Short Sharp |
112 | 3 = slow2 | 142 | 3 = Short Slow */ |
113 | 4 = NOS ? */ | ||
114 | long int value_hw = value; | ||
115 | #if defined(XDUOO_X3II) | 143 | #if defined(XDUOO_X3II) |
144 | long int value_hw = value; | ||
116 | alsa_controls_set_ints("AK4490 Digital Filter", 1, &value_hw); | 145 | alsa_controls_set_ints("AK4490 Digital Filter", 1, &value_hw); |
117 | #elif defined(XDUOO_X20) | 146 | #elif defined(XDUOO_X20) |
147 | long int value_hw = value; | ||
118 | alsa_controls_set_ints("ES9018_K2M Digital Filter", 1, &value_hw); | 148 | alsa_controls_set_ints("ES9018_K2M Digital Filter", 1, &value_hw); |
119 | #else | 149 | #else |
120 | (void)value; | 150 | (void)value; |