예제 #1
0
static void max14688_irq_jack_removed (struct max14688 *me)
{
	cancel_delayed_work_sync(&me->det_work);

	max14688_disable_irq(me, IRQ_SWD);

	max14688_write_mode0(me, MAX14688_MODE_LOW);
	max14688_write_mode1(me, MAX14688_MODE_LOW);

	/* Make sure no button down */
	max14688_irq_button_released(me);

	if (unlikely(!__present_valid_jack(me))) {
		goto out;
	}

	log_dbg("jack %s removed\n", __current_jack_name(me));
	me->report_jack(me->dev, __current_jack(me), JACK_OUT_VALUE);

	/* release current jack */
	me->matched_jack = -1;
#ifdef CONFIG_LGE_EARJACK_DEBUGGER
	msm_serial_set_uart_console(lge_uart_console_should_enable_on_default());
#endif
out:
	return;
}
static void max14688_det_work (struct work_struct *work)
{
    struct max14688 *me = container_of(work, struct max14688, det_work.work);
    int micZ, leftZ;

    if(earjack_detect == true) {
	    log_dbg("duplication intterupt already connect earjack\n");
	    return;
    } else {
	    earjack_detect = true;
    }

    __lock(me);

    if (unlikely(!me->detect_jack(me->dev))) {
	    log_warn("no jack in detection work\n");
	    earjack_detect = false;
	    goto out;
    }

    max14688_update_status(me);

    /* Read MIC and L-line impedences */
    micZ  = me->read_mic_impedence(me->dev);
    leftZ = me->read_left_impedence(me->dev);

    log_dbg("%s[micZ = %d, leftZ = %d\n", __func__, micZ, leftZ);

    /* Look up jack matching impedence ranges */
    max14688_lookup_jack(me, micZ, leftZ);

    if (unlikely(!__present_valid_jack(me))) {
	    earjack_detect = false;
	    goto no_match_found;
    }

    max14688_write_mode0(me, __current_jack_mode0(me));
    max14688_write_mode1(me, __current_jack_mode1(me));

    if (__current_jack_has_button(me)) {
	    max14688_enable_irq(me, IRQ_SWD);
    } else {
	    max14688_disable_irq(me, IRQ_SWD);
    }

    log_dbg("jack %s inserted\n", __current_jack_name(me));
    me->report_jack(me->dev, __current_jack(me), JACK_IN_VALUE);
    goto out;

no_match_found:
    /* Handle exception */
    log_err("unknown jack - mic %d, left %d\n", micZ, leftZ);

out:
    __unlock(me);
    return;
}
예제 #3
0
static void max14688_irq_jack_inserted (struct max14688 *me)
{
	unsigned long det_work_delay = msecs_to_jiffies(500);

#ifdef CONFIG_LGE_EARJACK_DEBUGGER
	msm_serial_set_uart_console(lge_uart_console_should_enable_on_default());
#endif

	/* Check INT bit and STATUS_INT bit for avoiding JIG mode */
	if (unlikely(max14688_get_status(me, STATUS_INT) && max14688_get_status(me, STATUS_MICIN))) {
		log_info("JIG power detected\n");

		max14688_disable_irq(me, IRQ_SWD);
#ifdef CONFIG_LGE_EARJACK_DEBUGGER
		msm_serial_set_uart_console(lge_uart_console_should_enable_on_earjack_debugger());
#endif
		me->matched_jack   = -1;
		me->matched_button = -1;
		goto out;
	}

	if (unlikely(__present_valid_jack(me))) {
		log_warn("new jack detected during insertion of jack %s\n",
				__current_jack_name(me));
#ifdef MAX14688_OVERWRITE_JACK_INSERTION
		max14688_irq_jack_removed(me);
#else
		goto out;
#endif
	}

	if (unlikely(delayed_work_pending(&me->det_work))) {
		log_warn("detection in progress\n");
		goto out;
	}

	log_dbg("%s\n", __func__);
	max14688_write_mode0(me, MAX14688_MODE_HIGH);
	max14688_write_mode1(me, MAX14688_MODE_LOW);

	schedule_delayed_work(&me->det_work, det_work_delay);

out:
	return;
}