⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tlv320.c

📁 嵌入式linux系统下hi3510平台的osd开发源码
💻 C
📖 第 1 页 / 共 2 页
字号:
                                which_ada = which_ada >> 28;
                                if((volume >0x1f )|| (volume<0x00))
                                	return -EINVAL;
                                gu8RegValue[which_ada][0] = volume;
                                hi_i2c_write(IIC_device_addr[which_ada], Lline_vol_ctrl,  \
                                gu8RegValue[which_ada][0]);
                                break;
    			case RIGHT_INPUT_VOLUME_MODIFY:
                                get_user(tmp,argp);
                                volume    =(tmp & 0x0fffffff); 
                                which_ada =(tmp & 0xf0000000);
                                which_ada = which_ada >> 28;
                                if((volume >0x1f )|| (volume<0x00))
                                	return -EINVAL;
                                gu8RegValue[which_ada][1] = volume;
                                hi_i2c_write(IIC_device_addr[which_ada], Rline_vol_ctrl,  \
                                gu8RegValue[which_ada][1]);
                                break;
    			case LINE_INPUT_MUTE:
                                get_user(tmp,argp);
                                which_ada =(tmp & 0xf0000000);
                                which_ada = which_ada >> 28;                                
                                which_chn = tmp & 0xff;
                                if(which_chn == 0x00)
                                {
                                    	hi_i2c_write(IIC_device_addr[which_ada], Lline_vol_ctrl, 0x00);
                                }
                                else if(which_chn == 0x01)
                                {
                                    	hi_i2c_write(IIC_device_addr[which_ada], Rline_vol_ctrl, 0x00);
                                }
                                else if(which_chn == 0x02)
                                {
                                    	hi_i2c_write(IIC_device_addr[which_ada], Rline_vol_ctrl,  0x00);
                                    	hi_i2c_write(IIC_device_addr[which_ada], Lline_vol_ctrl,  0x00);
                                }
                                else if(which_chn == 0x03)
                                {
                                    	hi_i2c_write(IIC_device_addr[which_ada], Rline_vol_ctrl,  0x17);
                                    	hi_i2c_write(IIC_device_addr[which_ada], Lline_vol_ctrl,  0x17);                                	    
                                }
                                else 
                                	    return -EINVAL;
                                break;
    			case MIC_INPUT_MUTE:      
    				                    tmp = gu8RegValue[u32PortIdx][4] | 0x02;
    				                    gu8RegValue[u32PortIdx][4] = tmp;                          
                                hi_i2c_write(IIC_device_addr[0],0x08,gu8RegValue[u32PortIdx][4]);
                                break;

    			case LEFT_HEADPHONE_VOLUME_MODIFY:
                                get_user(tmp,argp);                           
                                volume    = (tmp & 0x0fffffff);
                                which_ada = (tmp & 0xf0000000);
                                which_ada = which_ada >> 28;
                                if((volume >0x7f )|| (volume<0x00))
                                	return -EINVAL;
                                volume |= 0x80;
                                hi_i2c_write(IIC_device_addr[which_ada], Lhp_vol_ctrl, volume);
                                break;

    			case RIGHT_HEADPHONE_VOLUME_MODIFY:
                                get_user(tmp,argp);                  
                                volume    = (tmp & 0x0fffffff);
                                which_ada = (tmp & 0xf0000000);
                                which_ada = which_ada >> 28;
                                if((volume >0x7f )|| (volume<0x00))
                                	return -EINVAL;
                                volume |= 0x80;                      
                                hi_i2c_write(IIC_device_addr[which_ada], Rhp_vol_ctrl, volume);
                                break;
                                
    			case HEADPHONE_VOLUME_MUTE:
                                get_user(tmp,argp);                  
                                channel    = (tmp & 0x0fffffff);
                                which_ada = (tmp & 0xf0000000);
                                which_ada = which_ada >> 28;                                
                                if(channel == LEFT)
                                	hi_i2c_write(IIC_device_addr[which_ada],0x04,0x30);
                                else if(channel == RIGHT)
                                	hi_i2c_write(IIC_device_addr[which_ada],0x06,0x30);	
                                else
                                { 
                                	hi_i2c_write(IIC_device_addr[which_ada],0x04,0x30);
                                	hi_i2c_write(IIC_device_addr[which_ada],0x06,0x30);
                                }
                                break;
    			case SET_TLV_WORK_MODE:
                                get_user(tmp,argp);
                                channel    = (tmp & 0x0fffffff);
                                which_ada = (tmp & 0xf0000000);
                                which_ada = which_ada >> 28;                                  
                                if(channel == 0x00)
                                	hi_i2c_write(IIC_device_addr[which_ada],Digitl_intf_ctrl,0x42);
                                else 
                                	hi_i2c_write(IIC_device_addr[which_ada],Digitl_intf_ctrl,0x02);	

                                break;        
    			default:
        	                printk("Invalid Command!Exiting.\n");
        	                break;

        	}    
		return 0;
}



/*
 *  The various file operations we support.
 */
 
static struct file_operations tlv320_fops = {
	.owner		= THIS_MODULE,
	.ioctl		= tlv320_ioctl,
	.open		=  tlv320_open,
	.release	= tlv320_close
};

static struct miscdevice tlv320_dev = {
	MISC_DYNAMIC_MINOR,
	"tlv320",
	&tlv320_fops,
};

static int tlv320_device_init(void)
{
        /* inite codec configs.*/
        u32PortIdx = 0;
    	hi_i2c_write(IIC_device_addr[0], Reset_reg, 0x00);
    	hi_i2c_write(IIC_device_addr[0], Lline_vol_ctrl,   gu8RegValue[u32PortIdx][0]);
    	hi_i2c_write(IIC_device_addr[0], Rline_vol_ctrl,   gu8RegValue[u32PortIdx][1]);
    	hi_i2c_write(IIC_device_addr[0], Lhp_vol_ctrl,     gu8RegValue[u32PortIdx][2]);
    	hi_i2c_write(IIC_device_addr[0], Rhp_vol_ctrl,     gu8RegValue[u32PortIdx][3]);
    	hi_i2c_write(IIC_device_addr[0], Analog_path_ctrl, gu8RegValue[u32PortIdx][4]);
    	hi_i2c_write(IIC_device_addr[0], Digitl_path_ctrl, gu8RegValue[u32PortIdx][5]);
    	hi_i2c_write(IIC_device_addr[0], Power_down_ctrl,  gu8RegValue[u32PortIdx][6]);
    	hi_i2c_write(IIC_device_addr[0], Digitl_intf_ctrl, gu8RegValue[u32PortIdx][7]); 
    	hi_i2c_write(IIC_device_addr[0], Sample_rate_ctrl, gu8RegValue[u32PortIdx][8]); 
    	hi_i2c_write(IIC_device_addr[0], Digitl_intf_activ,gu8RegValue[u32PortIdx][9]);
    	
    	u32PortIdx = 1;
    	hi_i2c_write(IIC_device_addr[1], Reset_reg, 0x00);
    	hi_i2c_write(IIC_device_addr[1], Lline_vol_ctrl,   gu8RegValue[u32PortIdx][0]);
    	hi_i2c_write(IIC_device_addr[1], Rline_vol_ctrl,   gu8RegValue[u32PortIdx][1]);
    	hi_i2c_write(IIC_device_addr[1], Lhp_vol_ctrl,     gu8RegValue[u32PortIdx][2]);
    	hi_i2c_write(IIC_device_addr[1], Rhp_vol_ctrl,     gu8RegValue[u32PortIdx][3]);
    	hi_i2c_write(IIC_device_addr[1], Analog_path_ctrl, gu8RegValue[u32PortIdx][4]);
    	hi_i2c_write(IIC_device_addr[1], Digitl_path_ctrl, gu8RegValue[u32PortIdx][5]);
    	hi_i2c_write(IIC_device_addr[1], Power_down_ctrl,  gu8RegValue[u32PortIdx][6]);
    	hi_i2c_write(IIC_device_addr[1], Digitl_intf_ctrl, gu8RegValue[u32PortIdx][7]); 
    	hi_i2c_write(IIC_device_addr[1], Sample_rate_ctrl, gu8RegValue[u32PortIdx][8]); 
    	hi_i2c_write(IIC_device_addr[1], Digitl_intf_activ,gu8RegValue[u32PortIdx][9]); 
    	return 0;
}   	
    	
static int __init tlv320_init(void)
{
    	unsigned int ret;
    	ret = misc_register(&tlv320_dev);
    	if(ret)
    	{
    		printk("could not register tlv320 devices. \n");
    		return ret;
    	}
    	if(tlv320_device_init()<0){
    		misc_deregister(&tlv320_dev);
    		printk("tlv320 driver init fail for device init error!\n");
    		return -1;
    	}
    	printk("tlv320 driver init successful!\n");
    	return ret; 
}

static void __exit tlv320_exit(void)
{
    misc_deregister(&tlv320_dev);
}

module_init(tlv320_init);
module_exit(tlv320_exit);

#ifdef MODULE
#include <linux/compile.h>
#endif

MODULE_INFO(build, UTS_VERSION);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("hisilicon");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -