Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
Source at commit 56adfdeb4d5a6693ddd184aed817bbcbeb40c75b created 12 years 11 hours ago. By Xiangfu, m1/patches/rtems: milkymist-audio-add-support-mic-boost.patch preserve the mic boost setting | |
---|---|
1 | Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c |
2 | =================================================================== |
3 | --- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c 2012-03-27 14:03:04.065264002 +0800 |
4 | +++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c 2012-03-27 19:24:29.329264002 +0800 |
5 | @@ -47,6 +47,7 @@ |
6 | static int play_produce; |
7 | static int play_consume; |
8 | static int play_level; |
9 | +static int mic_boost; |
10 | |
11 | /* buffers played, for application to collect */ |
12 | static rtems_id play_q_done; |
13 | @@ -347,7 +348,7 @@ |
14 | |
15 | left = *val & 0xff; |
16 | left = (left*32)/100 - 1; |
17 | - if(left < 0) |
18 | + if (left < 0) |
19 | left = 0; |
20 | |
21 | if (mono) |
22 | @@ -355,7 +356,7 @@ |
23 | else { |
24 | right = (*val >> 8) & 0xff; |
25 | right = (right*32)/100 - 1; |
26 | - if(right < 0) |
27 | + if (right < 0) |
28 | right = 0; |
29 | } |
30 | |
31 | @@ -365,6 +366,13 @@ |
32 | else |
33 | codec = (31-left) | ((31-right) << 8); |
34 | |
35 | + if (mono) { |
36 | + if (mic_boost) |
37 | + codec |= (1 << 6); |
38 | + else |
39 | + codec &= ~(1 << 6); |
40 | + } |
41 | + |
42 | if (!write_cr(chan, codec)) |
43 | sc = RTEMS_UNSATISFIED; |
44 | else |
45 | @@ -372,6 +380,41 @@ |
46 | return sc; |
47 | } |
48 | |
49 | +static rtems_status_code ioctl_read_mic_boost(void *buf, unsigned int chan) |
50 | +{ |
51 | + unsigned int *val = (unsigned int *)buf; |
52 | + int codec; |
53 | + |
54 | + codec = read_cr(chan); |
55 | + if (codec < 0) |
56 | + return RTEMS_UNSATISFIED; |
57 | + |
58 | + *val = (codec & (1 << 6)) >> 6; |
59 | + return RTEMS_SUCCESSFUL; |
60 | +} |
61 | + |
62 | +static rtems_status_code ioctl_write_mic_boost(void *buf, unsigned int chan) |
63 | +{ |
64 | + unsigned int *val = (unsigned int *)buf; |
65 | + int codec; |
66 | + |
67 | + codec = read_cr(chan); |
68 | + if (codec < 0) |
69 | + return RTEMS_UNSATISFIED; |
70 | + |
71 | + if (*val) |
72 | + codec |= (1 << 6); |
73 | + else |
74 | + codec &= ~(1 << 6); |
75 | + |
76 | + if (!write_cr(chan, codec)) |
77 | + return RTEMS_UNSATISFIED; |
78 | + |
79 | + mic_boost = codec; |
80 | + |
81 | + return RTEMS_SUCCESSFUL; |
82 | +} |
83 | + |
84 | rtems_device_driver ac97_control( |
85 | rtems_device_major_number major, |
86 | rtems_device_minor_number minor, |
87 | @@ -419,6 +462,16 @@ |
88 | if(sc == RTEMS_SUCCESSFUL) |
89 | args->ioctl_return = 0; |
90 | return sc; |
91 | + case SOUND_MIXER_READ(SOUND_MIXER_MIC_BOOST): |
92 | + sc = ioctl_read_mic_boost(args->buffer, 0x0e); |
93 | + if(sc == RTEMS_SUCCESSFUL) |
94 | + args->ioctl_return = 0; |
95 | + return sc; |
96 | + case SOUND_MIXER_WRITE(SOUND_MIXER_MIC_BOOST): |
97 | + sc = ioctl_write_mic_boost(args->buffer, 0x0e); |
98 | + if(sc == RTEMS_SUCCESSFUL) |
99 | + args->ioctl_return = 0; |
100 | + return sc; |
101 | default: |
102 | return RTEMS_UNSATISFIED; |
103 | } |
104 | Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/milkymist_ac97.h |
105 | =================================================================== |
106 | --- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_ac97/milkymist_ac97.h 2012-03-27 14:03:04.085264002 +0800 |
107 | +++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/milkymist_ac97.h 2012-03-27 14:03:21.753264002 +0800 |
108 | @@ -21,6 +21,7 @@ |
109 | /* Ioctls. 0x41 is 'A' */ |
110 | #define SOUND_MIXER_MIC 0x0 |
111 | #define SOUND_MIXER_LINE 0x1 |
112 | +#define SOUND_MIXER_MIC_BOOST 0x2 |
113 | #define SOUND_MIXER_READ(x) (0x4100+x) |
114 | #define SOUND_MIXER_WRITE(x) (0x4110+x) |
115 | |
116 |
Branches:
master