|
@@ -339,13 +339,13 @@ static int hdmi_eld_ctl_info(struct snd_kcontrol *kcontrol,
|
|
if (!per_pin) {
|
|
if (!per_pin) {
|
|
/* no pin is bound to the pcm */
|
|
/* no pin is bound to the pcm */
|
|
uinfo->count = 0;
|
|
uinfo->count = 0;
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
- return 0;
|
|
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
eld = &per_pin->sink_eld;
|
|
eld = &per_pin->sink_eld;
|
|
uinfo->count = eld->eld_valid ? eld->eld_size : 0;
|
|
uinfo->count = eld->eld_valid ? eld->eld_size : 0;
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
|
|
|
|
|
|
+ unlock:
|
|
|
|
+ mutex_unlock(&spec->pcm_lock);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -357,6 +357,7 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
|
|
struct hdmi_spec_per_pin *per_pin;
|
|
struct hdmi_spec_per_pin *per_pin;
|
|
struct hdmi_eld *eld;
|
|
struct hdmi_eld *eld;
|
|
int pcm_idx;
|
|
int pcm_idx;
|
|
|
|
+ int err = 0;
|
|
|
|
|
|
pcm_idx = kcontrol->private_value;
|
|
pcm_idx = kcontrol->private_value;
|
|
mutex_lock(&spec->pcm_lock);
|
|
mutex_lock(&spec->pcm_lock);
|
|
@@ -365,16 +366,15 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
|
|
/* no pin is bound to the pcm */
|
|
/* no pin is bound to the pcm */
|
|
memset(ucontrol->value.bytes.data, 0,
|
|
memset(ucontrol->value.bytes.data, 0,
|
|
ARRAY_SIZE(ucontrol->value.bytes.data));
|
|
ARRAY_SIZE(ucontrol->value.bytes.data));
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
- return 0;
|
|
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
- eld = &per_pin->sink_eld;
|
|
|
|
|
|
|
|
|
|
+ eld = &per_pin->sink_eld;
|
|
if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) ||
|
|
if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) ||
|
|
eld->eld_size > ELD_MAX_SIZE) {
|
|
eld->eld_size > ELD_MAX_SIZE) {
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
snd_BUG();
|
|
snd_BUG();
|
|
- return -EINVAL;
|
|
|
|
|
|
+ err = -EINVAL;
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
|
|
|
|
memset(ucontrol->value.bytes.data, 0,
|
|
memset(ucontrol->value.bytes.data, 0,
|
|
@@ -382,9 +382,10 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
|
|
if (eld->eld_valid)
|
|
if (eld->eld_valid)
|
|
memcpy(ucontrol->value.bytes.data, eld->eld_buffer,
|
|
memcpy(ucontrol->value.bytes.data, eld->eld_buffer,
|
|
eld->eld_size);
|
|
eld->eld_size);
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+ unlock:
|
|
|
|
+ mutex_unlock(&spec->pcm_lock);
|
|
|
|
+ return err;
|
|
}
|
|
}
|
|
|
|
|
|
static const struct snd_kcontrol_new eld_bytes_ctl = {
|
|
static const struct snd_kcontrol_new eld_bytes_ctl = {
|
|
@@ -1209,8 +1210,8 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
|
|
pin_idx = hinfo_to_pin_index(codec, hinfo);
|
|
pin_idx = hinfo_to_pin_index(codec, hinfo);
|
|
if (!spec->dyn_pcm_assign) {
|
|
if (!spec->dyn_pcm_assign) {
|
|
if (snd_BUG_ON(pin_idx < 0)) {
|
|
if (snd_BUG_ON(pin_idx < 0)) {
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
- return -EINVAL;
|
|
|
|
|
|
+ err = -EINVAL;
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
/* no pin is assigned to the PCM
|
|
/* no pin is assigned to the PCM
|
|
@@ -1218,16 +1219,13 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
|
|
*/
|
|
*/
|
|
if (pin_idx < 0) {
|
|
if (pin_idx < 0) {
|
|
err = hdmi_pcm_open_no_pin(hinfo, codec, substream);
|
|
err = hdmi_pcm_open_no_pin(hinfo, codec, substream);
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
- return err;
|
|
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx);
|
|
err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx);
|
|
- if (err < 0) {
|
|
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
- return err;
|
|
|
|
- }
|
|
|
|
|
|
+ if (err < 0)
|
|
|
|
+ goto unlock;
|
|
|
|
|
|
per_cvt = get_cvt(spec, cvt_idx);
|
|
per_cvt = get_cvt(spec, cvt_idx);
|
|
/* Claim converter */
|
|
/* Claim converter */
|
|
@@ -1264,12 +1262,11 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
|
|
per_cvt->assigned = 0;
|
|
per_cvt->assigned = 0;
|
|
hinfo->nid = 0;
|
|
hinfo->nid = 0;
|
|
snd_hda_spdif_ctls_unassign(codec, pcm_idx);
|
|
snd_hda_spdif_ctls_unassign(codec, pcm_idx);
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
- return -ENODEV;
|
|
|
|
|
|
+ err = -ENODEV;
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
/* Store the updated parameters */
|
|
/* Store the updated parameters */
|
|
runtime->hw.channels_min = hinfo->channels_min;
|
|
runtime->hw.channels_min = hinfo->channels_min;
|
|
runtime->hw.channels_max = hinfo->channels_max;
|
|
runtime->hw.channels_max = hinfo->channels_max;
|
|
@@ -1278,7 +1275,9 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
|
|
|
|
|
|
snd_pcm_hw_constraint_step(substream->runtime, 0,
|
|
snd_pcm_hw_constraint_step(substream->runtime, 0,
|
|
SNDRV_PCM_HW_PARAM_CHANNELS, 2);
|
|
SNDRV_PCM_HW_PARAM_CHANNELS, 2);
|
|
- return 0;
|
|
|
|
|
|
+ unlock:
|
|
|
|
+ mutex_unlock(&spec->pcm_lock);
|
|
|
|
+ return err;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -1867,7 +1866,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
struct snd_pcm_runtime *runtime = substream->runtime;
|
|
bool non_pcm;
|
|
bool non_pcm;
|
|
int pinctl;
|
|
int pinctl;
|
|
- int err;
|
|
|
|
|
|
+ int err = 0;
|
|
|
|
|
|
mutex_lock(&spec->pcm_lock);
|
|
mutex_lock(&spec->pcm_lock);
|
|
pin_idx = hinfo_to_pin_index(codec, hinfo);
|
|
pin_idx = hinfo_to_pin_index(codec, hinfo);
|
|
@@ -1879,13 +1878,12 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
|
|
pin_cvt_fixup(codec, NULL, cvt_nid);
|
|
pin_cvt_fixup(codec, NULL, cvt_nid);
|
|
snd_hda_codec_setup_stream(codec, cvt_nid,
|
|
snd_hda_codec_setup_stream(codec, cvt_nid,
|
|
stream_tag, 0, format);
|
|
stream_tag, 0, format);
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
- return 0;
|
|
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
|
|
|
|
if (snd_BUG_ON(pin_idx < 0)) {
|
|
if (snd_BUG_ON(pin_idx < 0)) {
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
- return -EINVAL;
|
|
|
|
|
|
+ err = -EINVAL;
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
per_pin = get_pin(spec, pin_idx);
|
|
per_pin = get_pin(spec, pin_idx);
|
|
pin_nid = per_pin->pin_nid;
|
|
pin_nid = per_pin->pin_nid;
|
|
@@ -1924,6 +1922,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
|
|
/* snd_hda_set_dev_select() has been called before */
|
|
/* snd_hda_set_dev_select() has been called before */
|
|
err = spec->ops.setup_stream(codec, cvt_nid, pin_nid,
|
|
err = spec->ops.setup_stream(codec, cvt_nid, pin_nid,
|
|
stream_tag, format);
|
|
stream_tag, format);
|
|
|
|
+ unlock:
|
|
mutex_unlock(&spec->pcm_lock);
|
|
mutex_unlock(&spec->pcm_lock);
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
@@ -1945,6 +1944,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
|
|
struct hdmi_spec_per_cvt *per_cvt;
|
|
struct hdmi_spec_per_cvt *per_cvt;
|
|
struct hdmi_spec_per_pin *per_pin;
|
|
struct hdmi_spec_per_pin *per_pin;
|
|
int pinctl;
|
|
int pinctl;
|
|
|
|
+ int err = 0;
|
|
|
|
|
|
if (hinfo->nid) {
|
|
if (hinfo->nid) {
|
|
pcm_idx = hinfo_to_pcm_index(codec, hinfo);
|
|
pcm_idx = hinfo_to_pcm_index(codec, hinfo);
|
|
@@ -1963,14 +1963,12 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
|
|
snd_hda_spdif_ctls_unassign(codec, pcm_idx);
|
|
snd_hda_spdif_ctls_unassign(codec, pcm_idx);
|
|
clear_bit(pcm_idx, &spec->pcm_in_use);
|
|
clear_bit(pcm_idx, &spec->pcm_in_use);
|
|
pin_idx = hinfo_to_pin_index(codec, hinfo);
|
|
pin_idx = hinfo_to_pin_index(codec, hinfo);
|
|
- if (spec->dyn_pcm_assign && pin_idx < 0) {
|
|
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
- return 0;
|
|
|
|
- }
|
|
|
|
|
|
+ if (spec->dyn_pcm_assign && pin_idx < 0)
|
|
|
|
+ goto unlock;
|
|
|
|
|
|
if (snd_BUG_ON(pin_idx < 0)) {
|
|
if (snd_BUG_ON(pin_idx < 0)) {
|
|
- mutex_unlock(&spec->pcm_lock);
|
|
|
|
- return -EINVAL;
|
|
|
|
|
|
+ err = -EINVAL;
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
per_pin = get_pin(spec, pin_idx);
|
|
per_pin = get_pin(spec, pin_idx);
|
|
|
|
|
|
@@ -1989,10 +1987,11 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
|
|
per_pin->setup = false;
|
|
per_pin->setup = false;
|
|
per_pin->channels = 0;
|
|
per_pin->channels = 0;
|
|
mutex_unlock(&per_pin->lock);
|
|
mutex_unlock(&per_pin->lock);
|
|
|
|
+ unlock:
|
|
mutex_unlock(&spec->pcm_lock);
|
|
mutex_unlock(&spec->pcm_lock);
|
|
}
|
|
}
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+ return err;
|
|
}
|
|
}
|
|
|
|
|
|
static const struct hda_pcm_ops generic_ops = {
|
|
static const struct hda_pcm_ops generic_ops = {
|