AIC3104_音频驱动

本文档详细介绍了AIC3104音频codec的驱动开发过程,包括通过I2C与CPU通信设置寄存器,以及IIS接口实现语音功能。驱动代码中包含了初始化数据和设备操作函数,如打开、关闭、控制设备等。同时,提供了读写寄存器的函数以及错误处理机制。
摘要由CSDN通过智能技术生成
这两周一直在调AIC3104的驱动,这是个音频codec芯片,可以实现语音对讲功能。
AIC3104是通过I2C方式与CPU通信,来设置寄存器,另外是IIS接口进行语音的Mic_in和Line_out功能。
 
下面是aic3104的驱动源代码:
/*   extdrv/peripheral/vda/adv7179.c
 *
 *
 * Copyright (c) 2006 Hisilicon Co., Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.
 *
 *
 * History:
 *     17-Apr-2006 create this file
 *
 */
#include <linux/unistd.h>
#include <linux/module.h>
//#include <linux/config.h>
#include <linux/errno.h>
#include <linux/miscdevice.h>
#include <linux/fcntl.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/proc_fs.h>
#include <linux/workqueue.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/io.h>
//#include <linux/kcom.h>
#include <linux/random.h>
//#include "stapp_main.h"
#include "sti7105.h"
#include "stsys.h"
#include "stddefs.h"
#include "sti2c.h"
#include "staudlx_aic3104.h"
//#include "stcommon.h"
//#include "stavmem.h"
///PRE-DEFINITIONS/
//module name string
#define MOD_STR     "aic3104"
#define MOD_STR_E    "aic3104 ERROR"
//chip and id register addr
#define CHIP_A_I2C_ADDR  0x30//0x30//0x18
#define I2C0 0x00
//#define TRUE (bool) 1
/***************************************************
 (1). AIC3104 I2S work mode
Define 0xd0 if work as master
Define 0x00 if work as slave
***************************************************/
#define AIC3104_WORK_MODE  0x00
/***************************************************
(2). Global debug info switch
***************************************************/
#define GLOBAL_DEBUG
//AIC3104 version info.
#define AIC3104_VER_MIN  0//  0~63
#define AIC3104_VER_SEC  0//  0~63
#define AIC3104_VER_MAJ  1//  0~31
#define AIC3104_VER_DAY  25// 1~31
#define AIC3104_VER_MON  3// 1~12
#define AIC3104_VER_YER  10// 00~63

static STI2C_Handle_t i2c_handle;
static int nbpages = 0, chains[2] = {0,0};
 
typedef enum _tagDRV_ERR_CODE_
{
 //general return code
 NO_ERROR = 0,
 ERR_NO_DEV ,
 ERR_GPIO_I2C_RD,
 ERR_GPIO_I2C_WR,
 ERR_VERSION_CHK,
 ERR_DRV_REG,
 ERR_OUT_OF_RANGE,
 ERR_INVALID_CMD
}DRV_ERR_CODE;
/*
ST_ErrorCode_t STI2C_Read (   STI2C_Handle_t Handle,         //chip, I2CHandle
                              U8             *Buffer_p,                     //read reg
                              U32            MaxLen,                       //MAX_BYTE_READ, 
                              U32            Timeout,                     //100,
                              U32            *ActLen_p)                //target buffer
ST_ErrorCode_t STI2C_Write(   STI2C_Handle_t Handle,// ----chip
                              const U8       *Buffer_p,           //write reg
                              U32            NumberToWrite,      // -- bytes
                              U32            Timeout,              //new
                              U32            *ActLen_p)         //  source buffer
//#define cfg_bytes_writ
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值