Skip to content

Commit 3e2f457

Browse files
takaswietiwai
authored andcommitted
ALSA: oxfw: move model-specific parameters from common structure
In previous commit, some members are moved from 'struct snd_oxfw' because they're model-specific. There are also the other model-specific parameters in 'struct device_info'. This commit moves these members to model-specific structure. Signed-off-by: Takashi Sakamoto <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 40540de commit 3e2f457

File tree

3 files changed

+39
-42
lines changed

3 files changed

+39
-42
lines changed

sound/firewire/oxfw/oxfw-spkr.c

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ struct fw_spkr {
1212
s16 volume[6];
1313
s16 volume_min;
1414
s16 volume_max;
15+
16+
unsigned int mixer_channels;
17+
u8 mute_fb_id;
18+
u8 volume_fb_id;
1519
};
1620

1721
enum control_action { CTL_READ, CTL_WRITE };
@@ -162,8 +166,8 @@ static int spkr_mute_put(struct snd_kcontrol *control,
162166
if (mute == spkr->mute)
163167
return 0;
164168

165-
err = avc_audio_feature_mute(oxfw->unit, oxfw->device_info->mute_fb_id,
166-
&mute, CTL_WRITE);
169+
err = avc_audio_feature_mute(oxfw->unit, spkr->mute_fb_id, &mute,
170+
CTL_WRITE);
167171
if (err < 0)
168172
return err;
169173
spkr->mute = mute;
@@ -178,7 +182,7 @@ static int spkr_volume_info(struct snd_kcontrol *control,
178182
struct fw_spkr *spkr = oxfw->spec;
179183

180184
info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
181-
info->count = oxfw->device_info->mixer_channels;
185+
info->count = spkr->mixer_channels;
182186
info->value.integer.min = spkr->volume_min;
183187
info->value.integer.max = spkr->volume_max;
184188

@@ -194,7 +198,7 @@ static int spkr_volume_get(struct snd_kcontrol *control,
194198
struct fw_spkr *spkr = oxfw->spec;
195199
unsigned int i;
196200

197-
for (i = 0; i < oxfw->device_info->mixer_channels; ++i)
201+
for (i = 0; i < spkr->mixer_channels; ++i)
198202
value->value.integer.value[channel_map[i]] = spkr->volume[i];
199203

200204
return 0;
@@ -210,7 +214,7 @@ static int spkr_volume_put(struct snd_kcontrol *control,
210214
s16 volume;
211215
int err;
212216

213-
for (i = 0; i < oxfw->device_info->mixer_channels; ++i) {
217+
for (i = 0; i < spkr->mixer_channels; ++i) {
214218
if (value->value.integer.value[i] < spkr->volume_min ||
215219
value->value.integer.value[i] > spkr->volume_max)
216220
return -EINVAL;
@@ -220,20 +224,19 @@ static int spkr_volume_put(struct snd_kcontrol *control,
220224
}
221225

222226
changed_channels = 0;
223-
for (i = 0; i < oxfw->device_info->mixer_channels; ++i)
227+
for (i = 0; i < spkr->mixer_channels; ++i)
224228
if (value->value.integer.value[channel_map[i]] !=
225229
spkr->volume[i])
226230
changed_channels |= 1 << (i + 1);
227231

228232
if (equal_values && changed_channels != 0)
229233
changed_channels = 1 << 0;
230234

231-
for (i = 0; i <= oxfw->device_info->mixer_channels; ++i) {
235+
for (i = 0; i <= spkr->mixer_channels; ++i) {
232236
volume = value->value.integer.value[channel_map[i ? i - 1 : 0]];
233237
if (changed_channels & (1 << i)) {
234238
err = avc_audio_feature_volume(oxfw->unit,
235-
oxfw->device_info->mute_fb_id,
236-
&volume,
239+
spkr->volume_fb_id, &volume,
237240
i, CTL_CURRENT, CTL_WRITE);
238241
if (err < 0)
239242
return err;
@@ -245,7 +248,7 @@ static int spkr_volume_put(struct snd_kcontrol *control,
245248
return changed_channels != 0;
246249
}
247250

248-
int snd_oxfw_add_spkr(struct snd_oxfw *oxfw)
251+
int snd_oxfw_add_spkr(struct snd_oxfw *oxfw, bool is_lacie)
249252
{
250253
static const struct snd_kcontrol_new controls[] = {
251254
{
@@ -272,30 +275,35 @@ int snd_oxfw_add_spkr(struct snd_oxfw *oxfw)
272275
return -ENOMEM;
273276
oxfw->spec = spkr;
274277

275-
err = avc_audio_feature_volume(oxfw->unit,
276-
oxfw->device_info->volume_fb_id,
277-
&spkr->volume_min,
278-
0, CTL_MIN, CTL_READ);
278+
if (is_lacie) {
279+
spkr->mixer_channels = 1;
280+
spkr->mute_fb_id = 0x01;
281+
spkr->volume_fb_id = 0x01;
282+
} else {
283+
spkr->mixer_channels = 6;
284+
spkr->mute_fb_id = 0x01;
285+
spkr->volume_fb_id = 0x02;
286+
}
287+
288+
err = avc_audio_feature_volume(oxfw->unit, spkr->volume_fb_id,
289+
&spkr->volume_min, 0, CTL_MIN, CTL_READ);
279290
if (err < 0)
280291
return err;
281-
err = avc_audio_feature_volume(oxfw->unit,
282-
oxfw->device_info->volume_fb_id,
283-
&spkr->volume_max,
284-
0, CTL_MAX, CTL_READ);
292+
err = avc_audio_feature_volume(oxfw->unit, spkr->volume_fb_id,
293+
&spkr->volume_max, 0, CTL_MAX, CTL_READ);
285294
if (err < 0)
286295
return err;
287296

288-
err = avc_audio_feature_mute(oxfw->unit, oxfw->device_info->mute_fb_id,
289-
&spkr->mute, CTL_READ);
297+
err = avc_audio_feature_mute(oxfw->unit, spkr->mute_fb_id, &spkr->mute,
298+
CTL_READ);
290299
if (err < 0)
291300
return err;
292301

293-
first_ch = oxfw->device_info->mixer_channels == 1 ? 0 : 1;
294-
for (i = 0; i < oxfw->device_info->mixer_channels; ++i) {
295-
err = avc_audio_feature_volume(oxfw->unit,
296-
oxfw->device_info->volume_fb_id,
297-
&spkr->volume[i],
298-
first_ch + i, CTL_CURRENT, CTL_READ);
302+
first_ch = spkr->mixer_channels == 1 ? 0 : 1;
303+
for (i = 0; i < spkr->mixer_channels; ++i) {
304+
err = avc_audio_feature_volume(oxfw->unit, spkr->volume_fb_id,
305+
&spkr->volume[i], first_ch + i,
306+
CTL_CURRENT, CTL_READ);
299307
if (err < 0)
300308
return err;
301309
}

sound/firewire/oxfw/oxfw.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,10 @@ static int detect_quirks(struct snd_oxfw *oxfw)
147147
* Add ALSA control elements for two models to keep compatibility to
148148
* old firewire-speaker module.
149149
*/
150-
if (oxfw->entry->vendor_id == VENDOR_GRIFFIN ||
151-
oxfw->entry->vendor_id == VENDOR_LACIE) {
152-
oxfw->device_info =
153-
(const struct device_info *)oxfw->entry->driver_data;
154-
return snd_oxfw_add_spkr(oxfw);
155-
}
150+
if (oxfw->entry->vendor_id == VENDOR_GRIFFIN)
151+
return snd_oxfw_add_spkr(oxfw, false);
152+
if (oxfw->entry->vendor_id == VENDOR_LACIE)
153+
return snd_oxfw_add_spkr(oxfw, true);
156154

157155
/*
158156
* TASCAM FireOne has physical control and requires a pair of additional
@@ -285,18 +283,12 @@ static const struct device_info griffin_firewave = {
285283
.driver_name = "FireWave",
286284
.vendor_name = "Griffin",
287285
.model_name = "FireWave",
288-
.mixer_channels = 6,
289-
.mute_fb_id = 0x01,
290-
.volume_fb_id = 0x02,
291286
};
292287

293288
static const struct device_info lacie_speakers = {
294289
.driver_name = "FWSpeakers",
295290
.vendor_name = "LaCie",
296291
.model_name = "FireWire Speakers",
297-
.mixer_channels = 1,
298-
.mute_fb_id = 0x01,
299-
.volume_fb_id = 0x01,
300292
};
301293

302294
static const struct ieee1394_device_id oxfw_id_table[] = {

sound/firewire/oxfw/oxfw.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ struct device_info {
3535
const char *driver_name;
3636
const char *vendor_name;
3737
const char *model_name;
38-
unsigned int mixer_channels;
39-
u8 mute_fb_id;
40-
u8 volume_fb_id;
4138
};
4239

4340
/* This is an arbitrary number for convinience. */
@@ -142,4 +139,4 @@ int snd_oxfw_create_midi(struct snd_oxfw *oxfw);
142139

143140
int snd_oxfw_create_hwdep(struct snd_oxfw *oxfw);
144141

145-
int snd_oxfw_add_spkr(struct snd_oxfw *oxfw);
142+
int snd_oxfw_add_spkr(struct snd_oxfw *oxfw, bool is_lacie);

0 commit comments

Comments
 (0)