Commit cc0db22a authored by Takashi Iwai's avatar Takashi Iwai

Merge branch 'fix/hda' into for-linus

parents fdfa6829 54f7190b
...@@ -42,7 +42,7 @@ static void snd_hda_generate_beep(struct work_struct *work) ...@@ -42,7 +42,7 @@ static void snd_hda_generate_beep(struct work_struct *work)
return; return;
/* generate tone */ /* generate tone */
snd_hda_codec_write_cache(codec, beep->nid, 0, snd_hda_codec_write(codec, beep->nid, 0,
AC_VERB_SET_BEEP_CONTROL, beep->tone); AC_VERB_SET_BEEP_CONTROL, beep->tone);
} }
...@@ -119,7 +119,7 @@ static void snd_hda_do_detach(struct hda_beep *beep) ...@@ -119,7 +119,7 @@ static void snd_hda_do_detach(struct hda_beep *beep)
beep->dev = NULL; beep->dev = NULL;
cancel_work_sync(&beep->beep_work); cancel_work_sync(&beep->beep_work);
/* turn off beep for sure */ /* turn off beep for sure */
snd_hda_codec_write_cache(beep->codec, beep->nid, 0, snd_hda_codec_write(beep->codec, beep->nid, 0,
AC_VERB_SET_BEEP_CONTROL, 0); AC_VERB_SET_BEEP_CONTROL, 0);
} }
...@@ -192,7 +192,7 @@ int snd_hda_enable_beep_device(struct hda_codec *codec, int enable) ...@@ -192,7 +192,7 @@ int snd_hda_enable_beep_device(struct hda_codec *codec, int enable)
beep->enabled = enable; beep->enabled = enable;
if (!enable) { if (!enable) {
/* turn off beep */ /* turn off beep */
snd_hda_codec_write_cache(beep->codec, beep->nid, 0, snd_hda_codec_write(beep->codec, beep->nid, 0,
AC_VERB_SET_BEEP_CONTROL, 0); AC_VERB_SET_BEEP_CONTROL, 0);
} }
if (beep->mode == HDA_BEEP_MODE_SWREG) { if (beep->mode == HDA_BEEP_MODE_SWREG) {
...@@ -239,8 +239,12 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) ...@@ -239,8 +239,12 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
mutex_init(&beep->mutex); mutex_init(&beep->mutex);
if (beep->mode == HDA_BEEP_MODE_ON) { if (beep->mode == HDA_BEEP_MODE_ON) {
beep->enabled = 1; int err = snd_hda_do_attach(beep);
snd_hda_do_register(&beep->register_work); if (err < 0) {
kfree(beep);
codec->beep = NULL;
return err;
}
} }
return 0; return 0;
...@@ -253,7 +257,7 @@ void snd_hda_detach_beep_device(struct hda_codec *codec) ...@@ -253,7 +257,7 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
if (beep) { if (beep) {
cancel_work_sync(&beep->register_work); cancel_work_sync(&beep->register_work);
cancel_delayed_work(&beep->unregister_work); cancel_delayed_work(&beep->unregister_work);
if (beep->enabled) if (beep->dev)
snd_hda_do_detach(beep); snd_hda_do_detach(beep);
codec->beep = NULL; codec->beep = NULL;
kfree(beep); kfree(beep);
......
...@@ -1327,11 +1327,13 @@ EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps); ...@@ -1327,11 +1327,13 @@ EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps);
*/ */
u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid) u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid)
{ {
u32 pincap = snd_hda_query_pin_caps(codec, nid); u32 pincap;
if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
if (!codec->no_trigger_sense) {
pincap = snd_hda_query_pin_caps(codec, nid);
if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
}
return snd_hda_codec_read(codec, nid, 0, return snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_PIN_SENSE, 0); AC_VERB_GET_PIN_SENSE, 0);
} }
......
...@@ -817,6 +817,7 @@ struct hda_codec { ...@@ -817,6 +817,7 @@ struct hda_codec {
unsigned int pin_amp_workaround:1; /* pin out-amp takes index unsigned int pin_amp_workaround:1; /* pin out-amp takes index
* (e.g. Conexant codecs) * (e.g. Conexant codecs)
*/ */
unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */
#ifdef CONFIG_SND_HDA_POWER_SAVE #ifdef CONFIG_SND_HDA_POWER_SAVE
unsigned int power_on :1; /* current (global) power-state */ unsigned int power_on :1; /* current (global) power-state */
unsigned int power_transition :1; /* power-state in transition */ unsigned int power_transition :1; /* power-state in transition */
......
...@@ -356,6 +356,7 @@ struct azx_dev { ...@@ -356,6 +356,7 @@ struct azx_dev {
*/ */
unsigned char stream_tag; /* assigned stream */ unsigned char stream_tag; /* assigned stream */
unsigned char index; /* stream index */ unsigned char index; /* stream index */
int device; /* last device number assigned to */
unsigned int opened :1; unsigned int opened :1;
unsigned int running :1; unsigned int running :1;
...@@ -1441,10 +1442,13 @@ static int __devinit azx_codec_configure(struct azx *chip) ...@@ -1441,10 +1442,13 @@ static int __devinit azx_codec_configure(struct azx *chip)
*/ */
/* assign a stream for the PCM */ /* assign a stream for the PCM */
static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream) static inline struct azx_dev *
azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
{ {
int dev, i, nums; int dev, i, nums;
if (stream == SNDRV_PCM_STREAM_PLAYBACK) { struct azx_dev *res = NULL;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
dev = chip->playback_index_offset; dev = chip->playback_index_offset;
nums = chip->playback_streams; nums = chip->playback_streams;
} else { } else {
...@@ -1453,10 +1457,15 @@ static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream) ...@@ -1453,10 +1457,15 @@ static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream)
} }
for (i = 0; i < nums; i++, dev++) for (i = 0; i < nums; i++, dev++)
if (!chip->azx_dev[dev].opened) { if (!chip->azx_dev[dev].opened) {
chip->azx_dev[dev].opened = 1; res = &chip->azx_dev[dev];
return &chip->azx_dev[dev]; if (res->device == substream->pcm->device)
break;
} }
return NULL; if (res) {
res->opened = 1;
res->device = substream->pcm->device;
}
return res;
} }
/* release the assigned stream */ /* release the assigned stream */
...@@ -1505,7 +1514,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream) ...@@ -1505,7 +1514,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
int err; int err;
mutex_lock(&chip->open_mutex); mutex_lock(&chip->open_mutex);
azx_dev = azx_assign_device(chip, substream->stream); azx_dev = azx_assign_device(chip, substream);
if (azx_dev == NULL) { if (azx_dev == NULL) {
mutex_unlock(&chip->open_mutex); mutex_unlock(&chip->open_mutex);
return -EBUSY; return -EBUSY;
......
...@@ -1186,6 +1186,8 @@ static int patch_ad1986a(struct hda_codec *codec) ...@@ -1186,6 +1186,8 @@ static int patch_ad1986a(struct hda_codec *codec)
*/ */
spec->multiout.no_share_stream = 1; spec->multiout.no_share_stream = 1;
codec->no_trigger_sense = 1;
return 0; return 0;
} }
...@@ -1371,6 +1373,8 @@ static int patch_ad1983(struct hda_codec *codec) ...@@ -1371,6 +1373,8 @@ static int patch_ad1983(struct hda_codec *codec)
codec->patch_ops = ad198x_patch_ops; codec->patch_ops = ad198x_patch_ops;
codec->no_trigger_sense = 1;
return 0; return 0;
} }
...@@ -1813,6 +1817,9 @@ static int patch_ad1981(struct hda_codec *codec) ...@@ -1813,6 +1817,9 @@ static int patch_ad1981(struct hda_codec *codec)
codec->patch_ops.unsol_event = ad1981_hp_unsol_event; codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
break; break;
} }
codec->no_trigger_sense = 1;
return 0; return 0;
} }
...@@ -3118,6 +3125,8 @@ static int patch_ad1988(struct hda_codec *codec) ...@@ -3118,6 +3125,8 @@ static int patch_ad1988(struct hda_codec *codec)
#endif #endif
spec->vmaster_nid = 0x04; spec->vmaster_nid = 0x04;
codec->no_trigger_sense = 1;
return 0; return 0;
} }
...@@ -3330,6 +3339,8 @@ static int patch_ad1884(struct hda_codec *codec) ...@@ -3330,6 +3339,8 @@ static int patch_ad1884(struct hda_codec *codec)
codec->patch_ops = ad198x_patch_ops; codec->patch_ops = ad198x_patch_ops;
codec->no_trigger_sense = 1;
return 0; return 0;
} }
...@@ -4287,6 +4298,8 @@ static int patch_ad1884a(struct hda_codec *codec) ...@@ -4287,6 +4298,8 @@ static int patch_ad1884a(struct hda_codec *codec)
break; break;
} }
codec->no_trigger_sense = 1;
return 0; return 0;
} }
...@@ -4623,6 +4636,9 @@ static int patch_ad1882(struct hda_codec *codec) ...@@ -4623,6 +4636,9 @@ static int patch_ad1882(struct hda_codec *codec)
spec->mixers[2] = ad1882_6stack_mixers; spec->mixers[2] = ad1882_6stack_mixers;
break; break;
} }
codec->no_trigger_sense = 1;
return 0; return 0;
} }
......
...@@ -4453,14 +4453,7 @@ static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) ...@@ -4453,14 +4453,7 @@ static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
{ {
if (!nid) if (!nid)
return 0; return 0;
/* NOTE: we can't use snd_hda_jack_detect() here because STAC/IDT return snd_hda_jack_detect(codec, nid);
* codecs behave wrongly when SET_PIN_SENSE is triggered, although
* the pincap gives TRIG_REQ bit.
*/
if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0) &
AC_PINSENSE_PRESENCE)
return 1;
return 0;
} }
static void stac92xx_line_out_detect(struct hda_codec *codec, static void stac92xx_line_out_detect(struct hda_codec *codec,
...@@ -4962,6 +4955,7 @@ static int patch_stac9200(struct hda_codec *codec) ...@@ -4962,6 +4955,7 @@ static int patch_stac9200(struct hda_codec *codec)
if (spec == NULL) if (spec == NULL)
return -ENOMEM; return -ENOMEM;
codec->no_trigger_sense = 1;
codec->spec = spec; codec->spec = spec;
spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
spec->pin_nids = stac9200_pin_nids; spec->pin_nids = stac9200_pin_nids;
...@@ -5024,6 +5018,7 @@ static int patch_stac925x(struct hda_codec *codec) ...@@ -5024,6 +5018,7 @@ static int patch_stac925x(struct hda_codec *codec)
if (spec == NULL) if (spec == NULL)
return -ENOMEM; return -ENOMEM;
codec->no_trigger_sense = 1;
codec->spec = spec; codec->spec = spec;
spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
spec->pin_nids = stac925x_pin_nids; spec->pin_nids = stac925x_pin_nids;
...@@ -5108,6 +5103,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec) ...@@ -5108,6 +5103,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
if (spec == NULL) if (spec == NULL)
return -ENOMEM; return -ENOMEM;
codec->no_trigger_sense = 1;
codec->spec = spec; codec->spec = spec;
codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
...@@ -5255,6 +5251,7 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) ...@@ -5255,6 +5251,7 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
if (spec == NULL) if (spec == NULL)
return -ENOMEM; return -ENOMEM;
codec->no_trigger_sense = 1;
codec->spec = spec; codec->spec = spec;
codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
spec->digbeep_nid = 0x21; spec->digbeep_nid = 0x21;
...@@ -5418,6 +5415,7 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) ...@@ -5418,6 +5415,7 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
if (spec == NULL) if (spec == NULL)
return -ENOMEM; return -ENOMEM;
codec->no_trigger_sense = 1;
codec->spec = spec; codec->spec = spec;
codec->patch_ops = stac92xx_patch_ops; codec->patch_ops = stac92xx_patch_ops;
spec->num_pins = STAC92HD71BXX_NUM_PINS; spec->num_pins = STAC92HD71BXX_NUM_PINS;
...@@ -5661,6 +5659,7 @@ static int patch_stac922x(struct hda_codec *codec) ...@@ -5661,6 +5659,7 @@ static int patch_stac922x(struct hda_codec *codec)
if (spec == NULL) if (spec == NULL)
return -ENOMEM; return -ENOMEM;
codec->no_trigger_sense = 1;
codec->spec = spec; codec->spec = spec;
spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
spec->pin_nids = stac922x_pin_nids; spec->pin_nids = stac922x_pin_nids;
...@@ -5764,6 +5763,7 @@ static int patch_stac927x(struct hda_codec *codec) ...@@ -5764,6 +5763,7 @@ static int patch_stac927x(struct hda_codec *codec)
if (spec == NULL) if (spec == NULL)
return -ENOMEM; return -ENOMEM;
codec->no_trigger_sense = 1;
codec->spec = spec; codec->spec = spec;
codec->slave_dig_outs = stac927x_slave_dig_outs; codec->slave_dig_outs = stac927x_slave_dig_outs;
spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
...@@ -5898,6 +5898,7 @@ static int patch_stac9205(struct hda_codec *codec) ...@@ -5898,6 +5898,7 @@ static int patch_stac9205(struct hda_codec *codec)
if (spec == NULL) if (spec == NULL)
return -ENOMEM; return -ENOMEM;
codec->no_trigger_sense = 1;
codec->spec = spec; codec->spec = spec;
spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
spec->pin_nids = stac9205_pin_nids; spec->pin_nids = stac9205_pin_nids;
...@@ -6053,6 +6054,7 @@ static int patch_stac9872(struct hda_codec *codec) ...@@ -6053,6 +6054,7 @@ static int patch_stac9872(struct hda_codec *codec)
spec = kzalloc(sizeof(*spec), GFP_KERNEL); spec = kzalloc(sizeof(*spec), GFP_KERNEL);
if (spec == NULL) if (spec == NULL)
return -ENOMEM; return -ENOMEM;
codec->no_trigger_sense = 1;
codec->spec = spec; codec->spec = spec;
spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
spec->pin_nids = stac9872_pin_nids; spec->pin_nids = stac9872_pin_nids;
......
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