Commit ed360813 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Add codec->pcm_format_first flag

Introduced a new flag to set up the PCM stream format at first before
the stream_id and channel tag.  Some codecs (e.g. CA0132) seem
preferring this over stream_id -> format order.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 012e7eb1
...@@ -1386,6 +1386,44 @@ int snd_hda_codec_configure(struct hda_codec *codec) ...@@ -1386,6 +1386,44 @@ int snd_hda_codec_configure(struct hda_codec *codec)
} }
EXPORT_SYMBOL_HDA(snd_hda_codec_configure); EXPORT_SYMBOL_HDA(snd_hda_codec_configure);
/* update the stream-id if changed */
static void update_pcm_stream_id(struct hda_codec *codec,
struct hda_cvt_setup *p, hda_nid_t nid,
u32 stream_tag, int channel_id)
{
unsigned int oldval, newval;
if (p->stream_tag != stream_tag || p->channel_id != channel_id) {
oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
newval = (stream_tag << 4) | channel_id;
if (oldval != newval)
snd_hda_codec_write(codec, nid, 0,
AC_VERB_SET_CHANNEL_STREAMID,
newval);
p->stream_tag = stream_tag;
p->channel_id = channel_id;
}
}
/* update the format-id if changed */
static void update_pcm_format(struct hda_codec *codec, struct hda_cvt_setup *p,
hda_nid_t nid, int format)
{
unsigned int oldval;
if (p->format_id != format) {
oldval = snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_STREAM_FORMAT, 0);
if (oldval != format) {
msleep(1);
snd_hda_codec_write(codec, nid, 0,
AC_VERB_SET_STREAM_FORMAT,
format);
}
p->format_id = format;
}
}
/** /**
* snd_hda_codec_setup_stream - set up the codec for streaming * snd_hda_codec_setup_stream - set up the codec for streaming
* @codec: the CODEC to set up * @codec: the CODEC to set up
...@@ -1400,7 +1438,6 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, ...@@ -1400,7 +1438,6 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
{ {
struct hda_codec *c; struct hda_codec *c;
struct hda_cvt_setup *p; struct hda_cvt_setup *p;
unsigned int oldval, newval;
int type; int type;
int i; int i;
...@@ -1413,29 +1450,13 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, ...@@ -1413,29 +1450,13 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
p = get_hda_cvt_setup(codec, nid); p = get_hda_cvt_setup(codec, nid);
if (!p) if (!p)
return; return;
/* update the stream-id if changed */
if (p->stream_tag != stream_tag || p->channel_id != channel_id) { if (codec->pcm_format_first)
oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0); update_pcm_format(codec, p, nid, format);
newval = (stream_tag << 4) | channel_id; update_pcm_stream_id(codec, p, nid, stream_tag, channel_id);
if (oldval != newval) if (!codec->pcm_format_first)
snd_hda_codec_write(codec, nid, 0, update_pcm_format(codec, p, nid, format);
AC_VERB_SET_CHANNEL_STREAMID,
newval);
p->stream_tag = stream_tag;
p->channel_id = channel_id;
}
/* update the format-id if changed */
if (p->format_id != format) {
oldval = snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_STREAM_FORMAT, 0);
if (oldval != format) {
msleep(1);
snd_hda_codec_write(codec, nid, 0,
AC_VERB_SET_STREAM_FORMAT,
format);
}
p->format_id = format;
}
p->active = 1; p->active = 1;
p->dirty = 0; p->dirty = 0;
......
...@@ -861,6 +861,7 @@ struct hda_codec { ...@@ -861,6 +861,7 @@ struct hda_codec {
unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */ unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */
unsigned int ignore_misc_bit:1; /* ignore MISC_NO_PRESENCE bit */ unsigned int ignore_misc_bit:1; /* ignore MISC_NO_PRESENCE bit */
unsigned int no_jack_detect:1; /* Machine has no jack-detection */ unsigned int no_jack_detect:1; /* Machine has no jack-detection */
unsigned int pcm_format_first:1; /* PCM format must be set first */
#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 */
int power_transition; /* power-state in transition */ int power_transition; /* power-state in transition */
......
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