linux耳机和耳机上按键的探测识别驱动原理【展讯8810平台】

这篇博客详细介绍了在Linux环境下,针对展讯8810平台如何实现耳机插入检测和耳机上的按键识别的驱动程序。包括`headset.h`和`headset.c`两个文件,涉及GPIO、中断处理、定时器等技术,用于识别耳机插入状态和按键事件。
摘要由CSDN通过智能技术生成

 

=====================  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) { }

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值