提交 f8fb1170 编写于 作者: T Takashi Iwai

ALSA: hda - Use standard hda_jack infrastructure for CA0132 driver

For its headphone, mic and DSP responses, we can use the standard
hda_jack infrastructure in CA0132 driver, too.  The only point to
handle carefully is the delayed headphone jack handling.  It tries to
react after a certain delay.  Here we use the existing block_report
flag in hda_jack_tbl (that was implemented for HDMI).
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 7c3008c4
...@@ -3224,8 +3224,14 @@ static void ca0132_unsol_hp_delayed(struct work_struct *work) ...@@ -3224,8 +3224,14 @@ static void ca0132_unsol_hp_delayed(struct work_struct *work)
{ {
struct ca0132_spec *spec = container_of( struct ca0132_spec *spec = container_of(
to_delayed_work(work), struct ca0132_spec, unsol_hp_work); to_delayed_work(work), struct ca0132_spec, unsol_hp_work);
struct hda_jack_tbl *jack;
ca0132_select_out(spec->codec); ca0132_select_out(spec->codec);
snd_hda_jack_report_sync(spec->codec); jack = snd_hda_jack_tbl_get(spec->codec, UNSOL_TAG_HP);
if (jack) {
jack->block_report = 0;
snd_hda_jack_report_sync(spec->codec);
}
} }
static void ca0132_set_dmic(struct hda_codec *codec, int enable); static void ca0132_set_dmic(struct hda_codec *codec, int enable);
...@@ -4114,12 +4120,6 @@ static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc) ...@@ -4114,12 +4120,6 @@ static void init_input(struct hda_codec *codec, hda_nid_t pin, hda_nid_t adc)
} }
} }
static void ca0132_init_unsol(struct hda_codec *codec)
{
snd_hda_jack_detect_enable(codec, UNSOL_TAG_HP);
snd_hda_jack_detect_enable(codec, UNSOL_TAG_AMIC1);
}
static void refresh_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir) static void refresh_amp_caps(struct hda_codec *codec, hda_nid_t nid, int dir)
{ {
unsigned int caps; unsigned int caps;
...@@ -4390,7 +4390,8 @@ static void ca0132_download_dsp(struct hda_codec *codec) ...@@ -4390,7 +4390,8 @@ static void ca0132_download_dsp(struct hda_codec *codec)
ca0132_set_dsp_msr(codec, true); ca0132_set_dsp_msr(codec, true);
} }
static void ca0132_process_dsp_response(struct hda_codec *codec) static void ca0132_process_dsp_response(struct hda_codec *codec,
struct hda_jack_callback *callback)
{ {
struct ca0132_spec *spec = codec->spec; struct ca0132_spec *spec = codec->spec;
...@@ -4403,38 +4404,31 @@ static void ca0132_process_dsp_response(struct hda_codec *codec) ...@@ -4403,38 +4404,31 @@ static void ca0132_process_dsp_response(struct hda_codec *codec)
dspio_clear_response_queue(codec); dspio_clear_response_queue(codec);
} }
static void ca0132_unsol_event(struct hda_codec *codec, unsigned int res) static void hp_callback(struct hda_codec *codec, struct hda_jack_callback *cb)
{ {
struct ca0132_spec *spec = codec->spec; struct ca0132_spec *spec = codec->spec;
unsigned int tag = (res >> AC_UNSOL_RES_TAG_SHIFT) & 0x3f;
if (tag == UNSOL_TAG_DSP) { /* Delay enabling the HP amp, to let the mic-detection
ca0132_process_dsp_response(codec); * state machine run.
} else { */
struct hda_jack_tbl *jack; cancel_delayed_work_sync(&spec->unsol_hp_work);
queue_delayed_work(codec->bus->workq, &spec->unsol_hp_work,
codec_dbg(codec, "snd_hda_jack_get_action: 0x%x\n", res); msecs_to_jiffies(500));
jack = snd_hda_jack_tbl_get_from_tag(codec, tag); cb->tbl->block_report = 1;
if (!jack) }
return;
switch (jack->nid) { static void amic_callback(struct hda_codec *codec, struct hda_jack_callback *cb)
case UNSOL_TAG_HP: {
/* Delay enabling the HP amp, to let the mic-detection ca0132_select_mic(codec);
* state machine run. }
*/
cancel_delayed_work_sync(&spec->unsol_hp_work); static void ca0132_init_unsol(struct hda_codec *codec)
queue_delayed_work(codec->bus->workq, {
&spec->unsol_hp_work, snd_hda_jack_detect_enable_callback(codec, UNSOL_TAG_HP, hp_callback);
msecs_to_jiffies(500)); snd_hda_jack_detect_enable_callback(codec, UNSOL_TAG_AMIC1,
break; amic_callback);
case UNSOL_TAG_AMIC1: snd_hda_jack_detect_enable_callback(codec, UNSOL_TAG_DSP,
ca0132_select_mic(codec); ca0132_process_dsp_response);
snd_hda_jack_report_sync(codec);
break;
default:
break;
}
}
} }
/* /*
...@@ -4445,8 +4439,6 @@ static void ca0132_unsol_event(struct hda_codec *codec, unsigned int res) ...@@ -4445,8 +4439,6 @@ static void ca0132_unsol_event(struct hda_codec *codec, unsigned int res)
static struct hda_verb ca0132_base_init_verbs[] = { static struct hda_verb ca0132_base_init_verbs[] = {
/*enable ct extension*/ /*enable ct extension*/
{0x15, VENDOR_CHIPIO_CT_EXTENSIONS_ENABLE, 0x1}, {0x15, VENDOR_CHIPIO_CT_EXTENSIONS_ENABLE, 0x1},
/*enable DSP node unsol, needed for DSP download*/
{0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | UNSOL_TAG_DSP},
{} {}
}; };
...@@ -4563,6 +4555,8 @@ static int ca0132_init(struct hda_codec *codec) ...@@ -4563,6 +4555,8 @@ static int ca0132_init(struct hda_codec *codec)
snd_hda_power_up(codec); snd_hda_power_up(codec);
ca0132_init_unsol(codec);
ca0132_init_params(codec); ca0132_init_params(codec);
ca0132_init_flags(codec); ca0132_init_flags(codec);
snd_hda_sequence_write(codec, spec->base_init_verbs); snd_hda_sequence_write(codec, spec->base_init_verbs);
...@@ -4585,8 +4579,6 @@ static int ca0132_init(struct hda_codec *codec) ...@@ -4585,8 +4579,6 @@ static int ca0132_init(struct hda_codec *codec)
for (i = 0; i < spec->num_init_verbs; i++) for (i = 0; i < spec->num_init_verbs; i++)
snd_hda_sequence_write(codec, spec->init_verbs[i]); snd_hda_sequence_write(codec, spec->init_verbs[i]);
ca0132_init_unsol(codec);
ca0132_select_out(codec); ca0132_select_out(codec);
ca0132_select_mic(codec); ca0132_select_mic(codec);
...@@ -4614,7 +4606,7 @@ static struct hda_codec_ops ca0132_patch_ops = { ...@@ -4614,7 +4606,7 @@ static struct hda_codec_ops ca0132_patch_ops = {
.build_pcms = ca0132_build_pcms, .build_pcms = ca0132_build_pcms,
.init = ca0132_init, .init = ca0132_init,
.free = ca0132_free, .free = ca0132_free,
.unsol_event = ca0132_unsol_event, .unsol_event = snd_hda_jack_unsol_event,
}; };
static void ca0132_config(struct hda_codec *codec) static void ca0132_config(struct hda_codec *codec)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册