Commit 9c550218 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'sound-3.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
 "Here contains only the fixes for the new FireWire bebob driver.  All
  fairly trivial and local fixes, so safe to apply"

* tag 'sound-3.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
  ALSA: bebob: Correction for return value of special_clk_ctl_put() in error
  ALSA: bebob: Correction for return value of .put callback
  ALSA: bebob: Use different labels for digital input/output
  ALSA: bebob: Fix a missing to unlock mutex in error handling case
parents 051c2a9f eb12f72e
...@@ -379,11 +379,11 @@ static int special_clk_ctl_put(struct snd_kcontrol *kctl, ...@@ -379,11 +379,11 @@ static int special_clk_ctl_put(struct snd_kcontrol *kctl,
struct special_params *params = bebob->maudio_special_quirk; struct special_params *params = bebob->maudio_special_quirk;
int err, id; int err, id;
mutex_lock(&bebob->mutex);
id = uval->value.enumerated.item[0]; id = uval->value.enumerated.item[0];
if (id >= ARRAY_SIZE(special_clk_labels)) if (id >= ARRAY_SIZE(special_clk_labels))
return 0; return -EINVAL;
mutex_lock(&bebob->mutex);
err = avc_maudio_set_special_clk(bebob, id, err = avc_maudio_set_special_clk(bebob, id,
params->dig_in_fmt, params->dig_in_fmt,
...@@ -391,7 +391,10 @@ static int special_clk_ctl_put(struct snd_kcontrol *kctl, ...@@ -391,7 +391,10 @@ static int special_clk_ctl_put(struct snd_kcontrol *kctl,
params->clk_lock); params->clk_lock);
mutex_unlock(&bebob->mutex); mutex_unlock(&bebob->mutex);
return err >= 0; if (err >= 0)
err = 1;
return err;
} }
static struct snd_kcontrol_new special_clk_ctl = { static struct snd_kcontrol_new special_clk_ctl = {
.name = "Clock Source", .name = "Clock Source",
...@@ -434,8 +437,8 @@ static struct snd_kcontrol_new special_sync_ctl = { ...@@ -434,8 +437,8 @@ static struct snd_kcontrol_new special_sync_ctl = {
.get = special_sync_ctl_get, .get = special_sync_ctl_get,
}; };
/* Digital interface control for special firmware */ /* Digital input interface control for special firmware */
static char *const special_dig_iface_labels[] = { static char *const special_dig_in_iface_labels[] = {
"S/PDIF Optical", "S/PDIF Coaxial", "ADAT Optical" "S/PDIF Optical", "S/PDIF Coaxial", "ADAT Optical"
}; };
static int special_dig_in_iface_ctl_info(struct snd_kcontrol *kctl, static int special_dig_in_iface_ctl_info(struct snd_kcontrol *kctl,
...@@ -443,13 +446,13 @@ static int special_dig_in_iface_ctl_info(struct snd_kcontrol *kctl, ...@@ -443,13 +446,13 @@ static int special_dig_in_iface_ctl_info(struct snd_kcontrol *kctl,
{ {
einf->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; einf->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
einf->count = 1; einf->count = 1;
einf->value.enumerated.items = ARRAY_SIZE(special_dig_iface_labels); einf->value.enumerated.items = ARRAY_SIZE(special_dig_in_iface_labels);
if (einf->value.enumerated.item >= einf->value.enumerated.items) if (einf->value.enumerated.item >= einf->value.enumerated.items)
einf->value.enumerated.item = einf->value.enumerated.items - 1; einf->value.enumerated.item = einf->value.enumerated.items - 1;
strcpy(einf->value.enumerated.name, strcpy(einf->value.enumerated.name,
special_dig_iface_labels[einf->value.enumerated.item]); special_dig_in_iface_labels[einf->value.enumerated.item]);
return 0; return 0;
} }
...@@ -491,26 +494,36 @@ static int special_dig_in_iface_ctl_set(struct snd_kcontrol *kctl, ...@@ -491,26 +494,36 @@ static int special_dig_in_iface_ctl_set(struct snd_kcontrol *kctl,
unsigned int id, dig_in_fmt, dig_in_iface; unsigned int id, dig_in_fmt, dig_in_iface;
int err; int err;
mutex_lock(&bebob->mutex);
id = uval->value.enumerated.item[0]; id = uval->value.enumerated.item[0];
if (id >= ARRAY_SIZE(special_dig_in_iface_labels))
return -EINVAL;
/* decode user value */ /* decode user value */
dig_in_fmt = (id >> 1) & 0x01; dig_in_fmt = (id >> 1) & 0x01;
dig_in_iface = id & 0x01; dig_in_iface = id & 0x01;
mutex_lock(&bebob->mutex);
err = avc_maudio_set_special_clk(bebob, err = avc_maudio_set_special_clk(bebob,
params->clk_src, params->clk_src,
dig_in_fmt, dig_in_fmt,
params->dig_out_fmt, params->dig_out_fmt,
params->clk_lock); params->clk_lock);
if ((err < 0) || (params->dig_in_fmt > 0)) /* ADAT */ if (err < 0)
goto end;
/* For ADAT, optical interface is only available. */
if (params->dig_in_fmt > 0) {
err = 1;
goto end; goto end;
}
/* For S/PDIF, optical/coaxial interfaces are selectable. */
err = avc_audio_set_selector(bebob->unit, 0x00, 0x04, dig_in_iface); err = avc_audio_set_selector(bebob->unit, 0x00, 0x04, dig_in_iface);
if (err < 0) if (err < 0)
dev_err(&bebob->unit->device, dev_err(&bebob->unit->device,
"fail to set digital input interface: %d\n", err); "fail to set digital input interface: %d\n", err);
err = 1;
end: end:
special_stream_formation_set(bebob); special_stream_formation_set(bebob);
mutex_unlock(&bebob->mutex); mutex_unlock(&bebob->mutex);
...@@ -525,18 +538,22 @@ static struct snd_kcontrol_new special_dig_in_iface_ctl = { ...@@ -525,18 +538,22 @@ static struct snd_kcontrol_new special_dig_in_iface_ctl = {
.put = special_dig_in_iface_ctl_set .put = special_dig_in_iface_ctl_set
}; };
/* Digital output interface control for special firmware */
static char *const special_dig_out_iface_labels[] = {
"S/PDIF Optical and Coaxial", "ADAT Optical"
};
static int special_dig_out_iface_ctl_info(struct snd_kcontrol *kctl, static int special_dig_out_iface_ctl_info(struct snd_kcontrol *kctl,
struct snd_ctl_elem_info *einf) struct snd_ctl_elem_info *einf)
{ {
einf->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; einf->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
einf->count = 1; einf->count = 1;
einf->value.enumerated.items = ARRAY_SIZE(special_dig_iface_labels) - 1; einf->value.enumerated.items = ARRAY_SIZE(special_dig_out_iface_labels);
if (einf->value.enumerated.item >= einf->value.enumerated.items) if (einf->value.enumerated.item >= einf->value.enumerated.items)
einf->value.enumerated.item = einf->value.enumerated.items - 1; einf->value.enumerated.item = einf->value.enumerated.items - 1;
strcpy(einf->value.enumerated.name, strcpy(einf->value.enumerated.name,
special_dig_iface_labels[einf->value.enumerated.item + 1]); special_dig_out_iface_labels[einf->value.enumerated.item]);
return 0; return 0;
} }
...@@ -558,16 +575,20 @@ static int special_dig_out_iface_ctl_set(struct snd_kcontrol *kctl, ...@@ -558,16 +575,20 @@ static int special_dig_out_iface_ctl_set(struct snd_kcontrol *kctl,
unsigned int id; unsigned int id;
int err; int err;
mutex_lock(&bebob->mutex);
id = uval->value.enumerated.item[0]; id = uval->value.enumerated.item[0];
if (id >= ARRAY_SIZE(special_dig_out_iface_labels))
return -EINVAL;
mutex_lock(&bebob->mutex);
err = avc_maudio_set_special_clk(bebob, err = avc_maudio_set_special_clk(bebob,
params->clk_src, params->clk_src,
params->dig_in_fmt, params->dig_in_fmt,
id, params->clk_lock); id, params->clk_lock);
if (err >= 0) if (err >= 0) {
special_stream_formation_set(bebob); special_stream_formation_set(bebob);
err = 1;
}
mutex_unlock(&bebob->mutex); mutex_unlock(&bebob->mutex);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment