diff options
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 55108b5fb291..35090b3acbac 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -185,20 +185,19 @@ EXPORT_SYMBOL_HDA(snd_hda_get_jack_type); * Compose a 32bit command word to be sent to the HD-audio controller */ static inline unsigned int -make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, +make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int flags, unsigned int verb, unsigned int parm) { u32 val; - if ((codec->addr & ~0xf) || (direct & ~1) || (nid & ~0x7f) || + if ((codec->addr & ~0xf) || (nid & ~0x7f) || (verb & ~0xfff) || (parm & ~0xffff)) { - printk(KERN_ERR "hda-codec: out of range cmd %x:%x:%x:%x:%x\n", - codec->addr, direct, nid, verb, parm); + printk(KERN_ERR "hda-codec: out of range cmd %x:%x:%x:%x\n", + codec->addr, nid, verb, parm); return ~0; } val = (u32)codec->addr << 28; - val |= (u32)direct << 27; val |= (u32)nid << 20; val |= verb << 8; val |= parm; @@ -209,7 +208,7 @@ make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, * Send and receive a verb */ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd, - unsigned int *res) + int flags, unsigned int *res) { struct hda_bus *bus = codec->bus; int err; @@ -222,6 +221,8 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd, again: snd_hda_power_up(codec); mutex_lock(&bus->cmd_mutex); + if (flags & HDA_RW_NO_RESPONSE_FALLBACK) + bus->no_response_fallback = 1; for (;;) { trace_hda_send_cmd(codec, cmd); err = bus->ops.command(bus, cmd); @@ -234,6 +235,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd, *res = bus->ops.get_response(bus, codec->addr); trace_hda_get_response(codec, *res); } + bus->no_response_fallback = 0; mutex_unlock(&bus->cmd_mutex); snd_hda_power_down(codec); if (!codec_in_pm(codec) && res && *res == -1 && bus->rirb_error) { @@ -255,7 +257,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd, * snd_hda_codec_read - send a command and get the response * @codec: the HDA codec * @nid: NID to send the command - * @direct: direct flag + * @flags: optional bit flags * @verb: the verb to send * @parm: the parameter for the verb * @@ -264,12 +266,12 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd, * Returns the obtained response value, or -1 for an error. */ unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid, - int direct, + int flags, unsigned int verb, unsigned int parm) { - unsigned cmd = make_codec_cmd(codec, nid, direct, verb, parm); + unsigned cmd = make_codec_cmd(codec, nid, flags, verb, parm); unsigned int res; - if (codec_exec_verb(codec, cmd, &res)) + if (codec_exec_verb(codec, cmd, flags, &res)) return -1; return res; } @@ -279,7 +281,7 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_read); * snd_hda_codec_write - send a single command without waiting for response * @codec: the HDA codec * @nid: NID to send the command - * @direct: direct flag + * @flags: optional bit flags * @verb: the verb to send * @parm: the parameter for the verb * @@ -287,12 +289,12 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_read); * * Returns 0 if successful, or a negative error code. */ -int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct, - unsigned int verb, unsigned int parm) +int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags, + unsigned int verb, unsigned int parm) { - unsigned int cmd = make_codec_cmd(codec, nid, direct, verb, parm); + unsigned int cmd = make_codec_cmd(codec, nid, flags, verb, parm); unsigned int res; - return codec_exec_verb(codec, cmd, + return codec_exec_verb(codec, cmd, flags, codec->bus->sync_write ? &res : NULL); } EXPORT_SYMBOL_HDA(snd_hda_codec_write); @@ -3582,7 +3584,7 @@ EXPORT_SYMBOL_HDA(snd_hda_create_spdif_in_ctls); * snd_hda_codec_write_cache - send a single command with caching * @codec: the HDA codec * @nid: NID to send the command - * @direct: direct flag + * @flags: optional bit flags * @verb: the verb to send * @parm: the parameter for the verb * @@ -3591,7 +3593,7 @@ EXPORT_SYMBOL_HDA(snd_hda_create_spdif_in_ctls); * Returns 0 if successful, or a negative error code. */ int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid, - int direct, unsigned int verb, unsigned int parm) + int flags, unsigned int verb, unsigned int parm) { int err; struct hda_cache_head *c; @@ -3600,7 +3602,7 @@ int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid, cache_only = codec->cached_write; if (!cache_only) { - err = snd_hda_codec_write(codec, nid, direct, verb, parm); + err = snd_hda_codec_write(codec, nid, flags, verb, parm); if (err < 0) return err; } @@ -3624,7 +3626,7 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache); * snd_hda_codec_update_cache - check cache and write the cmd only when needed * @codec: the HDA codec * @nid: NID to send the command - * @direct: direct flag + * @flags: optional bit flags * @verb: the verb to send * @parm: the parameter for the verb * @@ -3635,7 +3637,7 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache); * Returns 0 if successful, or a negative error code. */ int snd_hda_codec_update_cache(struct hda_codec *codec, hda_nid_t nid, - int direct, unsigned int verb, unsigned int parm) + int flags, unsigned int verb, unsigned int parm) { struct hda_cache_head *c; u32 key; @@ -3651,7 +3653,7 @@ int snd_hda_codec_update_cache(struct hda_codec *codec, hda_nid_t nid, return 0; } mutex_unlock(&codec->bus->cmd_mutex); - return snd_hda_codec_write_cache(codec, nid, direct, verb, parm); + return snd_hda_codec_write_cache(codec, nid, flags, verb, parm); } EXPORT_SYMBOL_HDA(snd_hda_codec_update_cache); @@ -3806,11 +3808,13 @@ static unsigned int hda_set_power_state(struct hda_codec *codec, hda_nid_t fg = codec->afg ? codec->afg : codec->mfg; int count; unsigned int state; + int flags = 0; /* this delay seems necessary to avoid click noise at power-down */ if (power_state == AC_PWRST_D3) { /* transition time less than 10ms for power down */ msleep(codec->epss ? 10 : 100); + flags = HDA_RW_NO_RESPONSE_FALLBACK; } /* repeat power states setting at most 10 times*/ @@ -3819,7 +3823,7 @@ static unsigned int hda_set_power_state(struct hda_codec *codec, codec->patch_ops.set_power_state(codec, fg, power_state); else { - snd_hda_codec_read(codec, fg, 0, + snd_hda_codec_read(codec, fg, flags, AC_VERB_SET_POWER_STATE, power_state); snd_hda_codec_set_power_to_all(codec, fg, power_state); @@ -4461,12 +4465,13 @@ const char *snd_hda_pcm_type_name[HDA_PCM_NTYPES] = { /* * get the empty PCM device number to assign - * - * note the max device number is limited by HDA_MAX_PCMS, currently 10 */ -static int get_empty_pcm_device(struct hda_bus *bus, int type) +static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type) { /* audio device indices; not linear to keep compatibility */ + /* assigned to static slots up to dev#10; if more needed, assign + * the later slot dynamically (when CONFIG_SND_DYNAMIC_MINORS=y) + */ static int audio_idx[HDA_PCM_NTYPES][5] = { [HDA_PCM_TYPE_AUDIO] = { 0, 2, 4, 5, -1 }, [HDA_PCM_TYPE_SPDIF] = { 1, -1 }, @@ -4480,18 +4485,28 @@ static int get_empty_pcm_device(struct hda_bus *bus, int type) return -EINVAL; } - for (i = 0; audio_idx[type][i] >= 0 ; i++) + for (i = 0; audio_idx[type][i] >= 0; i++) { +#ifndef CONFIG_SND_DYNAMIC_MINORS + if (audio_idx[type][i] >= 8) + break; +#endif if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits)) return audio_idx[type][i]; + } +#ifdef CONFIG_SND_DYNAMIC_MINORS /* non-fixed slots starting from 10 */ for (i = 10; i < 32; i++) { if (!test_and_set_bit(i, bus->pcm_dev_bits)) return i; } +#endif snd_printk(KERN_WARNING "Too many %s devices\n", snd_hda_pcm_type_name[type]); +#ifndef CONFIG_SND_DYNAMIC_MINORS + snd_printk(KERN_WARNING "Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y\n"); +#endif return -EAGAIN; } |