More alsa git updates. (alsa-driver might compile against 2.6.27+ now.)
[gentoo-diskmaster-overlay.git] / media-libs / alsa-lib / files / git-update.patch
blobaee43f722182cfb94977697734f210ce0ec8bcae
1 diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
2 index a884b12..1170963 100644
3 --- a/src/pcm/pcm_direct.c
4 +++ b/src/pcm/pcm_direct.c
5 @@ -1107,7 +1107,7 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix)
6 snd_pcm_info_get_subdevice(info) * 2 + capture);
7 ret = snd_timer_open(&dmix->timer, name, SND_TIMER_OPEN_NONBLOCK | SND_TIMER_OPEN_TREAD);
8 if (ret < 0) {
9 - dmix->tread = 1;
10 + dmix->tread = 0;
11 ret = snd_timer_open(&dmix->timer, name, SND_TIMER_OPEN_NONBLOCK);
12 if (ret < 0) {
13 SNDERR("unable to open timer '%s'", name);
14 @@ -1293,7 +1293,7 @@ int snd_pcm_direct_check_interleave(snd_pcm_direct_t *dmix, snd_pcm_t *pcm)
15 const snd_pcm_channel_area_t *dst_areas;
16 const snd_pcm_channel_area_t *src_areas;
18 - bits = snd_pcm_format_physical_width(dmix->type);
19 + bits = snd_pcm_format_physical_width(pcm->format);
20 if ((bits % 8) != 0)
21 interleaved = 0;
22 channels = dmix->channels;
23 diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c
24 index c73a02b..c4f5b4a 100644
25 --- a/src/pcm/pcm_plugin.c
26 +++ b/src/pcm/pcm_plugin.c
27 @@ -203,7 +203,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t
28 snd_pcm_sframes_t n = snd_pcm_mmap_hw_avail(pcm);
29 snd_pcm_sframes_t sframes;
31 - if ((snd_pcm_uframes_t)n > frames)
32 + if ((snd_pcm_uframes_t)n < frames)
33 frames = n;
34 if (frames == 0)
35 return 0;
36 @@ -222,7 +222,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_rewind(snd_pcm_t *pcm, snd_pcm_uframes_t
37 frames = plugin->client_frames(pcm, sframes);
38 snd_pcm_mmap_appl_backward(pcm, (snd_pcm_uframes_t) frames);
39 snd_atomic_write_end(&plugin->watom);
40 - return n;
41 + return (snd_pcm_sframes_t) frames;
44 static snd_pcm_sframes_t snd_pcm_plugin_forwardable(snd_pcm_t *pcm)
45 @@ -234,9 +234,9 @@ static snd_pcm_sframes_t snd_pcm_plugin_forward(snd_pcm_t *pcm, snd_pcm_uframes_
47 snd_pcm_plugin_t *plugin = pcm->private_data;
48 snd_pcm_sframes_t n = snd_pcm_mmap_avail(pcm);
49 - snd_pcm_uframes_t sframes;
50 + snd_pcm_sframes_t sframes;
52 - if ((snd_pcm_uframes_t)n > frames)
53 + if ((snd_pcm_uframes_t)n < frames)
54 frames = n;
55 if (frames == 0)
56 return 0;
57 @@ -246,8 +246,8 @@ static snd_pcm_sframes_t snd_pcm_plugin_forward(snd_pcm_t *pcm, snd_pcm_uframes_
58 else
59 sframes = frames;
60 snd_atomic_write_begin(&plugin->watom);
61 - sframes = INTERNAL(snd_pcm_forward)(plugin->gen.slave, (snd_pcm_uframes_t) sframes);
62 - if ((snd_pcm_sframes_t) sframes < 0) {
63 + sframes = INTERNAL(snd_pcm_forward)(plugin->gen.slave, sframes);
64 + if (sframes < 0) {
65 snd_atomic_write_end(&plugin->watom);
66 return sframes;
68 @@ -255,7 +255,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_forward(snd_pcm_t *pcm, snd_pcm_uframes_
69 frames = plugin->client_frames(pcm, sframes);
70 snd_pcm_mmap_appl_forward(pcm, (snd_pcm_uframes_t) frames);
71 snd_atomic_write_end(&plugin->watom);
72 - return n;
73 + return (snd_pcm_sframes_t) frames;
76 static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm,
77 diff --git a/src/pcm/pcm_softvol.c b/src/pcm/pcm_softvol.c
78 index 7af7f40..eee6424 100644
79 --- a/src/pcm/pcm_softvol.c
80 +++ b/src/pcm/pcm_softvol.c
81 @@ -275,9 +275,15 @@ static void softvol_convert_stereo_vol(snd_pcm_softvol_t *svol,
82 return;
85 - vol[0] = svol->dB_value[svol->cur_vol[0]];
86 - vol[1] = svol->dB_value[svol->cur_vol[1]];
87 - vol_c = svol->dB_value[(svol->cur_vol[0] + svol->cur_vol[1]) / 2];
88 + if (svol->max_val == 1) {
89 + vol[0] = svol->cur_vol[0] ? 0xffff : 0;
90 + vol[1] = svol->cur_vol[1] ? 0xffff : 0;
91 + vol_c = vol[0] | vol[1];
92 + } else {
93 + vol[0] = svol->dB_value[svol->cur_vol[0]];
94 + vol[1] = svol->dB_value[svol->cur_vol[1]];
95 + vol_c = svol->dB_value[(svol->cur_vol[0] + svol->cur_vol[1]) / 2];
96 + }
97 switch (svol->sformat) {
98 case SND_PCM_FORMAT_S16_LE:
99 case SND_PCM_FORMAT_S16_BE:
100 @@ -325,7 +331,10 @@ static void softvol_convert_mono_vol(snd_pcm_softvol_t *svol,
101 return;
104 - vol_scale = svol->dB_value[svol->cur_vol[0]];
105 + if (svol->max_val == 1)
106 + vol_scale = svol->cur_vol[0] ? 0xffff : 0;
107 + else
108 + vol_scale = svol->dB_value[svol->cur_vol[0]];
109 switch (svol->sformat) {
110 case SND_PCM_FORMAT_S16_LE:
111 case SND_PCM_FORMAT_S16_BE:
112 @@ -569,9 +578,13 @@ static void snd_pcm_softvol_dump(snd_pcm_t *pcm, snd_output_t *out)
113 snd_pcm_softvol_t *svol = pcm->private_data;
114 snd_output_printf(out, "Soft volume PCM\n");
115 snd_output_printf(out, "Control: %s\n", svol->elem.id.name);
116 - snd_output_printf(out, "min_dB: %g\n", svol->min_dB);
117 - snd_output_printf(out, "max_dB: %g\n", svol->max_dB);
118 - snd_output_printf(out, "resolution: %d\n", svol->max_val + 1);
119 + if (svol->max_val == 1)
120 + snd_output_printf(out, "boolean\n");
121 + else {
122 + snd_output_printf(out, "min_dB: %g\n", svol->min_dB);
123 + snd_output_printf(out, "max_dB: %g\n", svol->max_dB);
124 + snd_output_printf(out, "resolution: %d\n", svol->max_val + 1);
126 if (pcm->setup) {
127 snd_output_printf(out, "Its setup is:\n");
128 snd_pcm_dump_setup(pcm, out);
129 @@ -596,13 +609,21 @@ static int add_user_ctl(snd_pcm_softvol_t *svol, snd_ctl_elem_info_t *cinfo, int
130 int i;
131 unsigned int def_val;
133 - err = snd_ctl_elem_add_integer(svol->ctl, &cinfo->id, count, 0, svol->max_val, 0);
134 + if (svol->max_val == 1)
135 + err = snd_ctl_elem_add_boolean(svol->ctl, &cinfo->id, count);
136 + else
137 + err = snd_ctl_elem_add_integer(svol->ctl, &cinfo->id, count,
138 + 0, svol->max_val, 0);
139 if (err < 0)
140 return err;
141 - add_tlv_info(svol, cinfo);
142 - /* set zero dB value as default, or max_val if
143 - there is no 0 dB setting */
144 - def_val = svol->zero_dB_val ? svol->zero_dB_val : svol->max_val;
145 + if (svol->max_val == 1)
146 + def_val = 1;
147 + else {
148 + add_tlv_info(svol, cinfo);
149 + /* set zero dB value as default, or max_val if
150 + there is no 0 dB setting */
151 + def_val = svol->zero_dB_val ? svol->zero_dB_val : svol->max_val;
153 for (i = 0; i < count; i++)
154 svol->elem.value.integer.value[i] = def_val;
155 return snd_ctl_elem_write(svol->ctl, &svol->elem);
156 @@ -647,7 +668,7 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol,
157 svol->max_val = resolution - 1;
158 svol->min_dB = min_dB;
159 svol->max_dB = max_dB;
160 - if (svol->max_dB == ZERO_DB)
161 + if (svol->max_val == 1 || svol->max_dB == ZERO_DB)
162 svol->zero_dB_val = svol->max_val;
163 else if (svol->max_dB < 0)
164 svol->zero_dB_val = 0; /* there is no 0 dB setting */
165 @@ -671,7 +692,8 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol,
166 /* hardware control exists */
167 return 1; /* notify */
169 - } else if (cinfo->type != SND_CTL_ELEM_TYPE_INTEGER ||
170 + } else if ((cinfo->type != SND_CTL_ELEM_TYPE_INTEGER &&
171 + cinfo->type != SND_CTL_ELEM_TYPE_BOOLEAN) ||
172 cinfo->count != (unsigned int)cchannels ||
173 cinfo->value.integer.min != 0 ||
174 cinfo->value.integer.max != resolution - 1) {
175 @@ -684,7 +706,7 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol,
176 SNDERR("Cannot add a control");
177 return err;
179 - } else {
180 + } else if (svol->max_val > 1) {
181 /* check TLV availability */
182 unsigned int tlv[4];
183 err = snd_ctl_elem_tlv_read(svol->ctl, &cinfo->id, tlv, sizeof(tlv));
184 @@ -693,6 +715,10 @@ static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol,
188 + if (svol->max_val == 1)
189 + return 0;
191 + /* set up dB table */
192 if (min_dB == PRESET_MIN_DB && max_dB == ZERO_DB && resolution == PRESET_RESOLUTION)
193 svol->dB_value = preset_dB_value;
194 else {
195 @@ -863,6 +889,7 @@ pcm.name {
196 [min_dB REAL] # minimal dB value (default: -51.0)
197 [max_dB REAL] # maximal dB value (default: 0.0)
198 [resolution INT] # resolution (default: 256)
199 + # resolution = 2 means a mute switch
201 \endcode
203 @@ -965,7 +992,7 @@ int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const char *name,
204 MAX_DB_UPPER_LIMIT);
205 return -EINVAL;
207 - if (resolution < 0 || resolution > 1024) {
208 + if (resolution <= 1 || resolution > 1024) {
209 SNDERR("Invalid resolution value %d", resolution);
210 return -EINVAL;