static void update_state(void)
{
    int state;

    if (hs->mic_on && hs->hs_on)
        state = 1 << 0;
    else if (hs->hs_on)
        state = 1 << 1;
    else if (hs->mic_on)
        state = 1 << 2;
    else
        state = 0;

    switch_set_state(&hs->sdev, state);
}
Ejemplo n.º 2
0
/* OPPO 2013-03-07 zhengzk Add begin for reason */
static int operate_display_switch(void)
{
    int ret = 0;
    printk("%s:state=%d.\n", __func__, te_state);

    spin_lock_irqsave(&te_state_lock, flags);
    if(te_state)
        te_state = 0;
    else
        te_state = 1;
    spin_unlock_irqrestore(&te_state_lock, flags);

    switch_set_state(&display_switch, te_state);
    return ret;
}
Ejemplo n.º 3
0
static ssize_t state_store(struct device *dev, struct device_attribute *attr,
			   const char *buf, size_t count)
{
	u32 state;
	ssize_t ret = 0;
	struct switch_dev *edev = (struct switch_dev *) dev_get_drvdata(dev);

	ret = sscanf(buf, "0x%x", &state);
	if (ret == 0)
		return -EINVAL;
	else
		switch_set_state(edev, state);

	return count;
}
Ejemplo n.º 4
0
/**********************************************************
 ** Function: Jack detection-in gpio configuration function
 ** Parameter: none
 ** Return value: if sucess, then returns 0
 **
 ************************************************************/
static int jack_config_gpio()
{
	int ret;

	printk("HEADSET: Config Jack-in detection gpio\n");
	hs_micbias_power(ON);
	ret = gpio_request(JACK_GPIO, "h2w_detect");
	ret = gpio_direction_input(JACK_GPIO);

	hs_data->irq = gpio_to_irq(JACK_GPIO);
	ret = request_irq(hs_data->irq, detect_irq_handler,
			IRQF_TRIGGER_FALLING|IRQF_TRIGGER_RISING, "h2w_detect", NULL);

	ret = irq_set_irq_wake(hs_data->irq, 1);

	switch (project_info) {
		case TEGRA3_PROJECT_TF201:
		case TEGRA3_PROJECT_TF300T:
		case TEGRA3_PROJECT_TF300TG:
		case TEGRA3_PROJECT_TF300TL:
		case TEGRA3_PROJECT_TF500T:
		case TEGRA3_PROJECT_TF700T:
		case TEGRA3_PROJECT_ME301T:
		case TEGRA3_PROJECT_ME301TL:
			/* delay 100ms to wait hook_det stable */
			msleep(100);
			break;
		case TEGRA3_PROJECT_P1801:
			/* delay 230ms to wait hook_det stable */
			msleep(230);
			break;
		default:
			/* delay 100ms to wait hook_det stable */
			msleep(100);
			break;
	}

	if (gpio_get_value(JACK_GPIO) == 0){
		insert_headset();
	}else {
		hs_micbias_power(OFF);
		headset_alive = false;
		switch_set_state(&hs_data->sdev, NO_DEVICE);
		remove_headset();
	}

	return 0;
}
Ejemplo n.º 5
0
static void musb_id_pin_work(struct work_struct *data)
{
	//bool is_ready = mtk_musb->is_ready;
	//u8 opstate = 0;
	down(&mtk_musb->musb_lock);
	DBG(0, "work start, is_host=%d\n", mtk_musb->is_host);
	if(mtk_musb->in_ipo_off) {
		DBG(0, "do nothing due to in_ipo_off\n");
		goto out;
	}
	//mtk_musb->is_ready = FALSE;
	mtk_musb ->is_host = musb_is_host();
	DBG(0,"musb is as %s\n",mtk_musb->is_host?"host":"device");
	switch_set_state((struct switch_dev *)&otg_state,mtk_musb->is_host);
	if(mtk_musb ->is_host) {
        	//setup fifo for host mode
        ep_config_from_table_for_host(mtk_musb);
    	wake_lock(&mtk_musb->usb_lock);
    	ignore_vbuserr = false;
		musb_set_vbus(mtk_musb,true);
		musb_start(mtk_musb);
		switch_int_to_device();
	} else {
		DBG(0,"devctl is %x\n",musb_readb(mtk_musb->mregs,MUSB_DEVCTL));
		dumpTime(funcWriteb, 0);
		musb_writeb(mtk_musb->mregs,MUSB_DEVCTL,0);
		wake_unlock(&mtk_musb->usb_lock);
		musb_set_vbus(mtk_musb,FALSE);
		/*
		opstate = musb_readb(mtk_musb->mregs,MUSB_OPSTATE);
		while(opstate != OTG_IDLE)
		{
			msleep(10);
			DBG(1,"wait OTG enter IDLE,opstate is %d\n",opstate);
			opstate = musb_readb(mtk_musb->mregs,MUSB_OPSTATE);
		}
		*/
        DBG(0,"musb_stop is called\n");
        //switch_int_to_host(); // move to musb_stop
		musb_stop(mtk_musb);

	}
	//mtk_musb->is_ready = is_ready;
out:
	DBG(0, "work end, is_host=%d\n", mtk_musb->is_host);
	up(&mtk_musb->musb_lock);

}
Ejemplo n.º 6
0
static void remove_headset(struct hsd_info *hi)
{
    int has_mic = switch_get_state(&hi->sdev);

    HSD_DBG("remove_headset");

    atomic_set(&hi->is_3_pole_or_not, HEADSET_POLE_INIT);
    mutex_lock(&hi->mutex_lock);
    switch_set_state(&hi->sdev, HEADSET_NO_DEVICE);
    mutex_unlock(&hi->mutex_lock);

    if (atomic_read(&hi->irq_key_enabled)) {
        unsigned long irq_flags;

        local_irq_save(irq_flags);
        disable_irq(hi->irq_key);
        local_irq_restore(irq_flags);
        atomic_set(&hi->irq_key_enabled, FALSE);
    }

    if( atomic_read(&hi->btn_state) == HEADSET_BTN_PRESSED )
#ifdef	CONFIG_MAX1462X_USE_LOCAL_WORK_QUEUE
        queue_delayed_work(local_max1462x_workqueue, &(hi->work_for_key_released), hi->latency_for_key );
#else
        schedule_delayed_work(&(hi->work_for_key_released), hi->latency_for_key );
#endif

    input_report_switch(hi->input, SW_HEADPHONE_INSERT, 0);

    if (has_mic == HEADSET_WITH_MIC) {
        irq_set_irq_wake(hi->irq_key, 0);
        input_report_switch(hi->input, SW_MICROPHONE_INSERT, 0);

//LGE_CHANGE_S 20130710 ilda.jung[Audio] Disable not using GPIO
#if !defined(CONFIG_MACH_APQ8064_AWIFI)
        // set low to an external LDO for mic bias
        if (hi->set_headset_mic_bias) {
            hi->set_headset_mic_bias(FALSE);
        } else if( hi->external_ldo_mic_bias > 0 ) {
            gpio_cansleep(hi->external_ldo_mic_bias) ?
            gpio_set_value_cansleep(hi->external_ldo_mic_bias, 0) : gpio_set_value(hi->external_ldo_mic_bias, 0);
        }
#endif
//LGE_CHANGE_E 20130710 ilda.jung[Audio] Disable not using GPIO
    }

    input_sync(hi->input);
}
Ejemplo n.º 7
0
static void Hp_mic_work(struct work_struct *work)
{
        int level = 0;
	struct rk_headset_pdata *pdata = headset_info->pdata;

	printk("hp_mic_work---------\n");
	mutex_lock(&headset_info->mutex_lock[MIC]);
        if(headset_info->headset_status == HEADSET_OUT)
        {
                printk("Headset is out\n");
                goto out;
        }
        level = read_gpio(pdata->Hook_gpio);
        if(level < 0)
                goto out;
        if((level > 0 && pdata->Hook_down_type == HOOK_DOWN_LOW)
                || (level == 0 && pdata->Hook_down_type == HOOK_DOWN_HIGH))
        {
                headset_info->isMic = 1;//have mic
                DBG("enable headset_hook irq\n");
                enable_irq(headset_info->irq[HOOK]);
                headset_info->isHook_irq = enable;
                headset_info->hook_status = HOOK_UP;
                if(pdata->Hook_down_type == HOOK_DOWN_HIGH)
                        irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_RISING);
                else
                        irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_FALLING);
		Switch_Mic_Mode(HP_MIC);

        }
        else
                headset_info->isMic= 0;//No microphone

        printk("headset->isMic = %d\n",headset_info->isMic);
        headset_info->cur_headset_status = headset_info->isMic ? BIT_HEADSET:BIT_HEADSET_NO_MIC;
        #if defined(CONFIG_SND_RK_SOC_RK2928)
        rk2928_codec_set_spk(HEADSET_IN);
        #endif
        rk28_send_wakeup_key();
        switch_set_state(&headset_info->sdev, headset_info->cur_headset_status);

        DBG("headset_info->cur_headset_status = %d\n",headset_info->cur_headset_status);

out:
	mutex_unlock(&headset_info->mutex_lock[MIC]);
        return;

}
Ejemplo n.º 8
0
void hdmi_send_audio_ch_num(
	int supported_ch_num, struct switch_dev *p_audio_ch_switch)
{
	if (last_uevent_state == HPD_LO) {
		printk(KERN_INFO	"[WARNING] %s() "
			"HDMI Audio ch = %d but not send\n",
			__func__, supported_ch_num);
		return;
	} else
		printk(KERN_INFO	"%s() "
			"HDMI Audio ch = %d\n",
			__func__, supported_ch_num);

	p_audio_ch_switch->state = 0;
	switch_set_state(p_audio_ch_switch, (int)supported_ch_num);
}
static void func_simdet_late_resume(struct early_suspend *es)
{
	sim_Status_after_resume = gpio_get_value(switch_data_priv->gpio);
	printk("%s: SimDet: late resume, status: %d\n",
			DRIVER_NAME,
			sim_Status_after_resume);

	if (sim_Status_after_resume != sim_Status) {
		printk("%s: Sim status changed from %d to %d\n",
				DRIVER_NAME,
				sim_Status,
				sim_Status_after_resume);
		sim_Status = sim_Status_after_resume;
		switch_set_state(&switch_data_priv->sdev, sim_Status);
	}
}
Ejemplo n.º 10
0
/**
 * hdmi_hpd_report - report hdmi hot plug state to user space
 * @hotplug:  0: hdmi plug out;   1:hdmi plug in
 *
 * always return success.
 */
__s32 Hdmi_hpd_event(__u32 event)
{
	//schedule_work(&ghdmi.hpd_work);
	if(!b_hdmi_suspend) {
#ifdef CONFIG_SWITCH
		__inf("hdmi_statue:%d\n", event);
		if(switch_get_state(&hdmi_switch_dev) != event) {
			switch_set_state(&hdmi_switch_dev, event);
			__inf("switch_set_state %d\n",event);
			disp_set_hdmi_hpd(event);
		}
#endif
	}

	return 0;
}
static void max98090_work(struct work_struct *work)
{
	struct max98090_priv *max98090 = container_of(work, struct max98090_priv, work.work);
	struct snd_soc_codec *codec= max98090->codec;
	int read_value=0;
//	int jack_auto_sts=0;

//	jack_auto_sts = snd_soc_read(codec, M98090_002_JACK_STS);

//	if(jack_man_sts&0x18){
		read_value = JACK_NO_DEVICE;
//	}
//	else if(jack_auto_sts&0x08){
//		read_value = HEADSET_4_POLE_DEVICE;
//	}
//	else {
//		read_value = JACK_NO_DEVICE;
//	}
	if(read_value != current_jack_type_status)
	{
		current_jack_type_status=read_value;
		switch_set_state(&switch_jack_detection, current_jack_type_status);
		mdelay(500);
		switch(current_jack_type_status)
		{
			case HEADSET_3_POLE_DEVICE :
			case HEADSET_4_POLE_DEVICE :
				max98090_disable_playback_path(codec, SPK);
				max98090_set_playback_speaker_headset(codec);
				max98090->cur_path = HP;
				break;
			case JACK_NO_DEVICE :
				max98090_disable_playback_path(codec, HP);
				max98090_set_playback_speaker_headset(codec);
				max98090->cur_path = SPK;
				break;
			default :
				max98090_disable_playback_path(codec, SPK);
				max98090_set_playback_speaker_headset(codec);
				max98090->cur_path = HP;
				break;
		}
		schedule_delayed_work(&max98090->work, msecs_to_jiffies(2000));
	}
	else schedule_delayed_work(&max98090->work, msecs_to_jiffies(1000));

}
Ejemplo n.º 12
0
static void remove_headset(struct work_struct *work)
{
	struct delayed_work *dwork = container_of(work, struct delayed_work, work);
	struct hsd_info *hi = container_of(dwork, struct hsd_info, work_for_remove);
	int has_mic = switch_get_state(&hi->sdev);

	int value = gpio_get_value_cansleep(hi->gpio_detect);

	if(value != EARJACK_REMOVED) {
		HSD_ERR("remove_headset but actually Fake removed state!!\n");
		return;
	}
	else {
		mutex_lock(&hi->mutex_lock);
		switch_set_state(&hi->sdev, NO_DEVICE);
		mutex_unlock(&hi->mutex_lock);
	}

	HSD_DBG("remove_headset");

	gpio_set_value_cansleep(hi->gpio_mic_en, 0);

	if (hi->set_headset_mic_bias)
		hi->set_headset_mic_bias(FALSE);

	atomic_set(&hi->is_3_pole_or_not, 1);

	if (atomic_read(&hi->irq_key_enabled)) {
		unsigned long irq_flags;

		local_irq_save(irq_flags);
		disable_irq(hi->irq_key);
		local_irq_restore(irq_flags);
		atomic_set(&hi->irq_key_enabled, FALSE);
	}

	if (atomic_read(&hi->btn_state)) {
		input_report_key(hi->input, hi->key_code, 0);
		input_sync(hi->input);
		atomic_set(&hi->btn_state, 0);
	}

	input_report_switch(hi->input, SW_HEADPHONE_INSERT, 0);
	if (has_mic == LGE_HEADSET)
		input_report_switch(hi->input, SW_MICROPHONE_INSERT, 0);
	input_sync(hi->input);
}
Ejemplo n.º 13
0
static void insert_35mm_do_work(struct work_struct *work)
{
	H2W_DBG("");
	hi->insert_jiffies = jiffies + 1*HZ;

	wake_lock_timeout(&hi->headset_wake_lock, 1.5*HZ);

	if (hi->is_ext_insert) {
		pr_info("3.5mm_headset plug in\n");

	if (pd->key_event_enable != NULL)
		pd->key_event_enable();

		/* Turn On Mic Bias */
		if (!hi->mic_bias_state) {
			turn_mic_bias_on(1);
			hi->mic_bias_state = 1;
			/* Wait for pin stable */
			msleep(300);
		}

		/* Detect headset with or without microphone */
		if(pd->headset_has_mic) {
			if (pd->headset_has_mic() == 0) {
				/* without microphone */
				pr_info("3.5mm without microphone\n");
				hi->ext_35mm_status = BIT_HEADSET_NO_MIC;
			} else { /* with microphone */
				pr_info("3.5mm with microphone\n");
				hi->ext_35mm_status = BIT_HEADSET;
			}
		} else {
			/* Assume no mic */
			pr_info("3.5mm without microphone\n");
			hi->ext_35mm_status = BIT_HEADSET_NO_MIC;
		}
		hi->ext_35mm_status |= BIT_35MM_HEADSET;

		/* Notify framework via switch class */
		mutex_lock(&hi->mutex_lock);
		switch_set_state(&hi->hs_change, hi->ext_35mm_status);
		mutex_unlock(&hi->mutex_lock);

		if (hi->is_hpin_stable)
			*(hi->is_hpin_stable) = 1;
	}
}
Ejemplo n.º 14
0
static void boot_cradle_det_func(void)
{
	int state;

	if (cradle->pdata->hallic_pouch_detect_pin)
		cradle->pouch = !gpio_get_value(cradle->pdata->hallic_pouch_detect_pin);

	printk("%s : boot pouch === > %d \n", __func__ , cradle->pouch);

#if defined CONFIG_HALLIC_PEN
	if (cradle->pdata->hallic_pen_detect_pin)
		cradle->pen = !gpio_get_value(cradle->pdata->hallic_pen_detect_pin);

	printk("%s : boot pen === > %d \n", __func__ , cradle->pen);

	if (cradle->pouch == 1)
		state = SMARTCOVER_POUCH_CLOSED;
	else if (cradle->pen == 1)
		state = SMARTCOVER_PEN_IN;
	else
		state = SMARTCOVER_POUCH_OPENED;
#else
	if (cradle->pdata->hallic_camera_detect_pin)
		cradle->camera = !gpio_get_value(cradle->pdata->hallic_camera_detect_pin);

	printk("%s : boot camera === > %d \n", __func__ , cradle->camera);

	if (cradle->pouch == 1 && cradle->camera == 1)
		state = SMARTCOVER_CAMERA_VIEW;
	else if (cradle->pouch == 1)
		state = SMARTCOVER_POUCH_CLOSED;
	else if (cradle->camera == 1)
		state = SMARTCOVER_CAMERA_OPENED;
	else
		state = SMARTCOVER_POUCH_OPENED;
#endif

	printk("%s : [Cradle] boot cradle value is %d\n", __func__ , state);
	cradle->state = state;
	wake_lock_timeout(&cradle->wake_lock, msecs_to_jiffies(3000));
	switch_set_state(&cradle->sdev, cradle->state);

	input_report_switch(cradle_input, SW_LID,
	        cradle->state == SMARTCOVER_POUCH_OPENED ? 0 : 1);
	input_sync(cradle_input);
}
Ejemplo n.º 15
0
int mdp_stop(struct v4l2_subdev *sd, void *arg)
{
	struct mdp_instance *inst = arg;
	int rc = 0;
	struct fb_info *fbi = NULL;
	if (inst) {
		rc = msm_fb_writeback_stop(inst->mdp);
		if (rc) {
			WFD_MSG_ERR("Failed to stop writeback mode\n");
			return rc;
		}
		fbi = (struct fb_info *)inst->mdp;
		switch_set_state(&inst->sdev, false);
		WFD_MSG_DBG("wfd state switched to %d\n", inst->sdev.state);
	}
	return 0;
}
Ejemplo n.º 16
0
static void lid_switch_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
{

    if (type == EV_SW && code == SW_TABLET_MODE )
    {
        printk(KERN_DEBUG "%s(%s): Event.  Type: %d, Code: %d, Value: %d   KEYPAD  : %s \n",__FILE__, __FUNCTION__,
               type, code, value , value ? "UNLOCKED":"LOCKED");

        adp5588_data.update_config = value+1;
        schedule_work(&adp5588_data.lock_work);
    }


    if (type == EV_SW && ((code == SW_TABLET_MODE) || (code == SW_LID)))
        switch_set_state(&adp5588_data.sw_lid_dev,
                         (switch_get_state(&adp5588_data.sw_lid_dev) & ~(1<<code)) | ( value << code) );
}
Ejemplo n.º 17
0
static int ear_switch_change(struct work_struct *ignored)
{
	int ear_state = 0;

	SEC_HEADSET_DBG("");
	if(!ip_dev){
    		dev_err(ip_dev->dev.parent,"Input Device not allocated\n");
    		return IRQ_HANDLED;
  	}
  
  	ear_state = gpio_get_value(EAR_KEY_GPIO) ^ EAR_KEY_INVERT_ENABLE;
	
  	if( ear_state < 0 ){
    	dev_err(ip_dev->dev.parent,"Failed to read GPIO value\n");
    	return IRQ_HANDLED;
  	}

	del_timer(&send_end_key_event_timer);
	send_end_key_timer_token = 0;	

	//gpio_direction_output(EAR_ADC_SEL_GPIO , 0);

	if((get_headset_status() == HEADSET_4POLE_WITH_MIC) && send_end_irq_token)//  4 pole headset connected && send irq enable
	{
		if(ear_state)
		{
			send_end_key_event_timer.expires = SEND_END_CHECK_TIME; // 10ms ??
			add_timer(&send_end_key_event_timer);		
			SEC_HEADSET_DBG("SEND/END %s.timer start \n", "pressed");
			
		}else{
			SEC_HEADSET_DBG(KERN_ERR "SISO:sendend isr work queue\n");    			
		 	input_report_key(ip_dev,KEYCODE_HEADSETHOOK,0);
  			input_sync(ip_dev);
			printk("SEND/END %s.\n", "released");
			earkey_stats = 0;
			switch_set_state(&switch_sendend, 0);
			//gpio_direction_output(EAR_ADC_SEL_GPIO , 1);
		}

	}else{
		SEC_HEADSET_DBG("SEND/END Button is %s but headset disconnect or irq disable.\n", ear_state?"pressed":"released");
	}

  return 0;
}
int switch_send_event(unsigned int bit, int on)
{
	unsigned long state;

	HS_DBG();

	mutex_lock(&hi->mutex_lock);
	state = switch_get_state(&hi->sdev_h2w);
	state &= ~(bit);

	if (on)
		state |= bit;

	switch_set_state(&hi->sdev_h2w, state);
	mutex_unlock(&hi->mutex_lock);
	return 0;
}
static int tegra_wm8903_jack_notifier(struct notifier_block *self,
			      unsigned long action, void *dev)
{
	struct snd_soc_jack *jack = dev;
	struct snd_soc_codec *codec = jack->codec;
	struct snd_soc_card *card = codec->card;
	struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
	enum headset_state state = BIT_NO_HEADSET;

	if (jack == &tegra_wm8903_hp_jack) {
		machine->jack_status &= ~SND_JACK_HEADPHONE;
		machine->jack_status |= (action & SND_JACK_HEADPHONE);
	} else {
		machine->jack_status &= ~SND_JACK_MICROPHONE;
		machine->jack_status |= (action & SND_JACK_MICROPHONE);
	}

	switch (machine->jack_status) {
#if defined(CONFIG_ARCH_ACER_T20) || defined(CONFIG_ARCH_ACER_T30)
	case SND_JACK_HEADPHONE:
	case SND_JACK_HEADSET:
		if (handset_mic_detect(codec)) {
			state = BIT_HEADSET;
		} else {
			state = BIT_HEADSET_NO_MIC;
		}
		break;
#else
	case SND_JACK_HEADPHONE:
		state = BIT_HEADSET_NO_MIC;
		break;
	case SND_JACK_HEADSET:
		state = BIT_HEADSET;
		break;
#endif
	case SND_JACK_MICROPHONE:
		/* mic: would not report */
	default:
		state = BIT_NO_HEADSET;
	}

	switch_set_state(&tegra_wm8903_headset_switch, state);

	return NOTIFY_OK;
}
Ejemplo n.º 20
0
static irqreturn_t felica_int_irq(int irq, void *dev)
{
	int state;
	struct felica_dev *d = dev;

	/* Read INT GPIO */
	state = d->flint->int_read(d);

	if (0 == state || 1 == state) {
		/* Update value of the switch device */
		switch_set_state(&d->swdev, state);
		dev_dbg(d->dev, "INT state = %d\n", state);
	} else {
		dev_err(d->dev, "%s: Error. Cannot read INT GPIO.\n", __func__);
	}

	return IRQ_HANDLED;
}
Ejemplo n.º 21
0
static void star_hall_intr_handler( void *arg )
{
	NvU32 gpio_status;
	//NvOdmGpioInterruptMask(g_hall->h_hall_intr, NV_TRUE );// NV_FALSE --> enable intr , NV_TRUE --> disable
	NvOdmGpioGetState(g_hall->h_hall_gpio, g_hall->h_hall_gpio_pin, &gpio_status );
	printk("--------------------------------------------------detecting value = %d\n", gpio_status);
	if( gpio_status == 0 )
		{atomic_set( &sensing_hall, 0 );input_report_abs(g_hall->input_device, ABS_HAT2X, 0);input_sync(g_hall->input_device);}
	else if( gpio_status == 1 )
		{atomic_set( &sensing_hall, 1 );input_report_abs(g_hall->input_device, ABS_HAT2X, 1);input_sync(g_hall->input_device);}

	//NvOdmGpioInterruptMask(g_hall->h_hall_intr, NV_FALSE);// NV_FALSE --> enable intr , NV_TRUE --> disable

	/* 2 == CAR */
	switch_set_state(&g_hall->sdev, gpio_status ? 0 : 2);

	NvOdmGpioInterruptDone(g_hall->h_hall_intr);
}
static void ep952_update_hpd_status(void)
{
    static unsigned char s_hpd_change_count = 0;
    unsigned char current_state = HDMI_Tx_hpd_state() ? 1 : 0;

    if(g_hpd_state != current_state) {
        if(s_hpd_change_count++ >= 10) {
            s_hpd_change_count = 0;
            g_hpd_state = current_state;
            if(current_state) {
                sunxi_edid_update(sunxi_edid);
            }
            switch_set_state(&hdmi_switch_dev, current_state);
        }
    } else {
        s_hpd_change_count = 0;
    }
}
Ejemplo n.º 23
0
static int simple_remote_remove(struct platform_device *pdev)
{
	struct simple_remote_driver *jack = platform_get_drvdata(pdev);

	if (switch_get_state(&jack->swdev)) {
		jack->interface->unregister_hssd_button_interrupt(jack);
		jack->interface->enable_mic_bias(0);
		switch_set_state(&jack->swdev, NO_DEVICE);
	}
	jack->interface->unregister_plug_detect_interrupt(jack);
	remove_sysfs_interfaces(&pdev->dev);
	input_unregister_device(jack->indev_appkey);
	input_unregister_device(jack->indev);
	switch_dev_unregister(&jack->swdev);
	kzfree(jack);

	return 0;
}
Ejemplo n.º 24
0
static void boot_cradle_det_func(void)
{
	int state;

	if (cradle->pdata->pouch_detect_pin)
		cradle->pouch = !gpio_get_value(cradle->pdata->pouch_detect_pin);

	pr_info("%s : boot pouch === > %d \n", __func__ , cradle->pouch);

	if (cradle->pouch == 1)
		state = CRADLE_SMARTCOVER;
	else
		state = CRADLE_SMARTCOVER_NO_DEV;

	pr_info("%s : [Cradle] boot cradle value is %d\n", __func__ , state);
	cradle->state = state;
	switch_set_state(&cradle->sdev, cradle->state);
}
Ejemplo n.º 25
0
/**
 * snd_jack_report - Report the current status of a jack
 *
 * @jack:   The jack to report status for
 * @status: The current status of the jack
 */
void snd_jack_report(struct snd_jack *jack, int status)
{
	int i;

	if (!jack)
		return;

	/* This is Android, headset information goes separately */
	switch (status & SND_JACK_HEADSET) {
	case SND_JACK_HEADSET:
	case SND_JACK_MICROPHONE:
		jack->sstatus = 1;
		break;
	case SND_JACK_HEADPHONE:
		jack->sstatus = 2;
		break;
	default:
		jack->sstatus = 0;
		break;
	}
	if (jack->registered){
		switch_set_state(&jack->sdev, jack->sstatus);
	}

	status &= ~SND_JACK_HEADSET;

	for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
		int testbit = SND_JACK_BTN_0 >> i;

		if (jack->type & testbit)
			input_report_key(jack->input_dev, jack->key[i],
					 status & testbit);
	}

	for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++) {
		int testbit = 1 << i;
		if (jack->type & testbit)
			input_report_switch(jack->input_dev,
					    jack_switch_types[i],
					    status & testbit);
	}

	input_sync(jack->input_dev);
}
Ejemplo n.º 26
0
void cradle_set_deskdock(int state)
{
	unsigned long flags;

	if (&cradle->sdev) {
		spin_lock_irqsave(&cradle->lock, flags);
		if (cradle->state != state) {
			cradle->state = state;
			spin_unlock_irqrestore(&cradle->lock, flags);
			wake_lock_timeout(&cradle->wake_lock, msecs_to_jiffies(3000));
			switch_set_state(&cradle->sdev, cradle->state);
		}
		else {
			spin_unlock_irqrestore(&cradle->lock, flags);
		}
	} else {
		pre_set_flag = state;
	}
}
Ejemplo n.º 27
0
static void fsa9485_dock_cb(int attached)
{
	union power_supply_propval value;
	int i, ret = 0;
	struct power_supply *psy;

	pr_info("fsa9480_dock_cb attached %d\n", attached);
	switch_set_state(&switch_dock, attached);

	set_cable_status = attached ? CABLE_TYPE_CARDOCK : CABLE_TYPE_NONE;

	for (i = 0; i < 10; i++) {
		psy = power_supply_get_by_name("battery");
		if (psy)
			break;
	}
	if (i == 10) {
		pr_err("%s: fail to get battery ps\n", __func__);
		return;
	}

	switch (set_cable_status) {
	case CABLE_TYPE_CARDOCK:
		value.intval = POWER_SUPPLY_TYPE_CARDOCK;
		break;
	case CABLE_TYPE_NONE:
		value.intval = POWER_SUPPLY_TYPE_BATTERY;
		break;
	default:
		pr_err("invalid status:%d\n", attached);
		return;
	}

	current_cable_type = value.intval;

	value.intval = current_cable_type<<ONLINE_TYPE_MAIN_SHIFT;
	ret = psy->set_property(psy, POWER_SUPPLY_PROP_ONLINE, &value);

	if (ret) {
		pr_err("%s: fail to set power_suppy ONLINE property(%d)\n",
			__func__, ret);
	}
}
static void remove_headset(void)
{
	unsigned long irq_flags;

	H2W_DBG("");

	switch_set_state(&hi->sdev, NO_DEVICE);
	configure_cpld(UART3);

	/*                */
	local_irq_save(irq_flags);
	disable_irq(hi->irq_btn);
	local_irq_restore(irq_flags);

	if (atomic_read(&hi->btn_state))
		button_released();

	hi->debounce_time = ktime_set(0, 100000000);  /*        */
}
Ejemplo n.º 29
0
static void  ns115_jd_work_func(struct work_struct *work)
{
	struct ns115_jd_pridata *jack = container_of(work, struct ns115_jd_pridata, work);
	int irqret, state, state_tmp, deb_cnt = 0;
	unsigned long irqflags;

	//delay 100 ms and check the gpio 5 times to avoid wrong state
	msleep(100);
	state = gpio_get_value(jack->gpio);
	for(deb_cnt = 0; deb_cnt < 5; )
	{
		msleep(60);
		state_tmp = gpio_get_value(jack->gpio);
		if(state == state_tmp)
		{
			deb_cnt++;
		}
		else
		{
			state = state_tmp;
			deb_cnt = 0;
		}
	}
	irqflags = state?IRQF_TRIGGER_FALLING:IRQF_TRIGGER_RISING;
	if(state != jack->report)
	{
		jack->report = state;
		if(!state){
			int value;
			value = rt5631_mic_gpio_check(state);
			if(value)
				state = BIT_HEADSET;
			else
				state = BIT_HEADSET_NO_MIC;	
		}else{
			state = 0;
		}
		switch_set_state(&jack->sdev, state);
	}
	free_irq(jack->irq, NULL);
	irqret = request_irq(jack->irq, ns115_jd_irq_handler, irqflags,
			"ns115-jd", NULL);
}
static void remove_headset(void)
{
#ifdef FEATURE_AUD_HOOK_BTN	
	unsigned long irq_flags;
#endif

    H2W_DBG("");
        /*SW-MM-RC-Mesona-03434[+*/
        if(bn_hook_state)
            button_released(KEY_MEDIA);
        if(bn_volup_state)
            button_released(KEY_VOLUMEUP);
        if(bn_voldown_state)
            button_released(KEY_VOLUMEDOWN);
        if(bn_live_state)
            button_released(BTN_3);
        /*SW-MM-RC-Mesona-03434]+*/
    hi->ignore_btn = 1;  /* FIH-SW2-MM-AY-TAP_Tapioca-00746_00 */
    pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_OFF); /* FIH-SW2-MM-AY-TAP-ControlHSED_BIAS1-01 */
	switch_set_state(&hi->sdev, NO_DEVICE);
		
  	input_sync(hi->hs_input);
#ifdef FEATURE_AUD_HOOK_BTN

	mHeadphone = false;

	if (bn_irq_enable) {
		
		local_irq_save(irq_flags);
		
		disable_irq(hi->irq_btn);

		local_irq_restore(irq_flags);
		
		bn_irq_enable=0;

		irq_set_irq_wake(hi->irq_btn, 0);
	}
	
	if (atomic_read(&hi->btn_state))
		button_released();
#endif
}