===================== headset.h =====================
/*
* Copyright (C) 2012 Spreadtrum Communications Inc.
* filename: headset.h
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __HEADSET_H__
#define __HEADSET_H__
enum {
BIT_HEADSET_OUT = 0,
BIT_HEADSET_MIC = (1 << 0),
BIT_HEADSET_NO_MIC = (1 << 1),
};
struct _headset_gpio {
int active_low;
int gpio;
int irq;
unsigned int irq_type_active;
unsigned int irq_type_inactive;
int debounce;
int debounce_sw;
int holded;
int active;
int irq_enabled;
const char *desc;
struct _headset *parent;
unsigned int timeout_ms;
struct hrtimer timer;
enum hrtimer_restart (*callback)(int active, struct _headset_gpio *hgp);
};
struct _headset {
struct switch_dev sdev;
struct input_dev *input;
struct _headset_gpio detect;
struct _headset_gpio button;
int headphone;
};
#endif
===================== headset.c =====================
/*
* Copyright (C) 2012 Spreadtrum Communications Inc.
* filename: headset.c
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/delay.h>
#include <linux/switch.h>
#include <linux/input.h>
#include <mach/gpio.h>
#include "headset.h"
#include <mach/board.h>
#define HEADSET_WITH_EIC
#ifdef HEADSET_WITH_EIC
#include <mach/eic.h>
#define HEADSET_DETECT_GPIO EIC_ID_13
#define HEADSET_BUTTON_GPIO EIC_ID_12
#define headset_gpio_init(gpio, desc) { }
#define headset_gpio_free(gpio) { }