<sxh c> static void wm8960_work_func(struct work_struct *work) {
struct wm8960_private_data *pdata = NULL; struct snd_soc_codec *codec = NULL; int flag = -1; int status = SND_JACK_HEADPHONE; int jack_type = 0;
pdata = container_of(work, struct wm8960_private_data, work); codec = (struct snd_soc_codec *)pdata->data;
flag = wm8960_detect_hp();
if(pdata->detect_flag != flag) { if(!use_antipop) { /* Enable anti pop mode */ snd_soc_update_bits(codec, WM8960_APOP1, WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_BUFDCOPEN, WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_BUFDCOPEN);
/* Enable VMID at 2*50k */ snd_soc_update_bits(codec, WM8960_POWER1, WM8960_VMID_MASK, 0x80);
/* Ramp */ msleep(100);
/* Enable VREF */ snd_soc_update_bits(codec, WM8960_POWER1, WM8960_VREF, WM8960_VREF);
msleep(100);
} if (flag == 1) {
#ifdef CONFIG_V2_HDMI_AUDIO
printk(KERN_INFO "wm8960 hp pluged\n");
/* Speaker */ snd_soc_update_bits(codec, WM8960_LOUT2, 0x7f, 0x0); snd_soc_update_bits(codec, WM8960_ROUT2, 0x7f, 0x0); /* Headphone */ snd_soc_update_bits(codec, WM8960_LOUT1, 0x7f, 0x7f); snd_soc_update_bits(codec, WM8960_ROUT1, 0x7f, 0x7f);
/* DAC Mono Mix clear */ snd_soc_update_bits(codec, WM8960_ADDCTL1, 1 << 4, 0); printk(" 1 === USYS_KKJ clear DAC Mono ===\n");
/* jack report */ snd_soc_jack_report(&pdata->jack, status, SND_JACK_HEADSET);
#else
snd_soc_update_bits(codec, WM8960_POWER1, 2, 2); msleep(100); jack_type = wm8960_detect_hp(); if(jack_type == 1){ printk("wm8960 3 ports hp pluged\n"); /* jack report */ snd_soc_jack_report(&pdata->jack, SND_JACK_HEADPHONE, SND_JACK_HEADPHONE); switch_set_state(&pdata->sdev, 2); }else{ printk("wm8960 4 ports hs pluged\n"); /* jack report */ snd_soc_jack_report(&pdata->jack, status, SND_JACK_HEADSET); switch_set_state(&pdata->sdev, 1); }
#endif
} else { printk(KERN_INFO "wm8960 hp unpluged\n");
#ifdef CONFIG_V2_HDMI_AUDIO
/* Speaker */ snd_soc_update_bits(codec, WM8960_LOUT2, 0x7f, 0x7f); snd_soc_update_bits(codec, WM8960_ROUT2, 0x7f, 0x7f); /* Headphone */ snd_soc_update_bits(codec, WM8960_LOUT1, 0x7f, 0x0); snd_soc_update_bits(codec, WM8960_ROUT1, 0x7f, 0x0);
/* DAC Mono Mix set */ snd_soc_update_bits(codec, WM8960_ADDCTL1, 1 << 4, 1 << 4); printk(" 1 === USYS_KKJ set DAC Mono ===\n");
#else #if 0
/* Speaker */ snd_soc_update_bits(codec, WM8960_LOUT2, 0x70, 0x70); snd_soc_update_bits(codec, WM8960_ROUT2, 0x70, 0x70); /* Headphone */ snd_soc_update_bits(codec, WM8960_LOUT1, 0x70, 0); snd_soc_update_bits(codec, WM8960_ROUT1, 0x70, 0);
/* DAC Mono Mix set */ snd_soc_update_bits(codec, WM8960_ADDCTL1, 1 << 4, 1 << 4);
#endif
switch_set_state(&pdata->sdev, 0);
#endif
/* jack report */ snd_soc_jack_report(&pdata->jack, 0, SND_JACK_HEADSET); }
pdata->detect_flag = flag; if(!use_antipop) {
/* Disable VMID and VREF */ snd_soc_update_bits(codec, WM8960_POWER1, WM8960_VREF | WM8960_VMID_MASK, 0);
/* Disable HP discharge */ snd_soc_update_bits(codec, WM8960_APOP2, WM8960_DISOP | WM8960_DRES_MASK, 0);
/* Disable anti-pop features */ snd_soc_update_bits(codec, WM8960_APOP1, WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_BUFDCOPEN, WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_BUFDCOPEN);
use_antipop = 1; } }
} </sxh>