Tda7415 has a small number of internal registers, a total of 32. Actually, only 0 ~ is used ~ 23 and 31. 0 ~ 23 is the function register, and 31 registers are used for testing. To debug this film, we recommend that you start with the test register and write 0x3e in it so that you can test a kHz signal on the corresponding pins. If this step succeeds, you can be assured that there is no problem with IIC communication and there is no problem with writing registers. Never take it for granted that IIC communication is faulty by reading registers. Next, configure the 24 registers according to its documents.
/*
* Init part
*/
Static const struct i2c_device_id tda7415_id [] = {
{"Tda7415-i2c", 0 },
{},
};
Module_device_table (I2C, tda7415_id );
Static struct i2c_driver tda7415_i2c_driver = {
. Driver = {
. Name = "tda7415-i2c ",
. Owner = this_module,
},
. Probe = tda7415_i2c_probe,
. Remove = _ devexit_p (tda7415_i2c_remove ),
. Id_table = tda7415_id,
};
Static int _ init alsa_tda7415t_init (void)
{
Return i2c_add_driver (& tda7415_i2c_driver );
}
Static void _ exit alsa_tda7415t_exit (void)
{
I2c_del_driver (& tda7415_i2c_driver );
}
Module_init (alsa_tda7415t_init );
Module_exit (alsa_tda7415t_exit );
Static _ devinit int tda7415_i2c_probe (struct i2c_client * client,
Const struct i2c_device_id * ID)
{
Struct tda7415_drvdata * drv_data;
Struct i2c_adapter * adapter = to_i2c_adapter (client-> Dev. Parent );
Printk ("Debug at func % s (), line % d by Tongjiang/N" ,__ function __,__ line __);
Drv_data = kmalloc (sizeof (struct tda7415_drvdata), gfp_kernel );
If (drv_data = NULL)
{
Printk (& client-> Dev, "Dev % s, lack of kernel memory! /N ");
Return-enomem;
}
If (! I2c_check_functionality (adapter, i2c_func_smbus_byte_data ))
{
Printk (& adapter-> Dev,
"Dev % s, I2C-Adapter doesn't support i2c_func_smbus_word/N ");
Return-EIO;
}
Drv_data-> client = client;
I2c_set_clientdata (client, drv_data );
Mutex_init (& drv_data-> lock );
Tda7415_init_client (client );
Return 0;
}
Static struct i2c_board_info mxc_i2c0_board_info [] _ initdata = {
{
. Type = "ov3640 ",
. ADDR = 0x3c,
. Platform_data = (void *) & camera_data,
},
{
. Type = "tda7415-i2c ",
. ADDR = 0x46,
}
};
Static int tda7415_init_client (struct i2c_client * client)
{
Int I;
Struct tda7415_drvdata * tda7415_data = i2c_get_clientdata (client );
U8 reg;
U8 data;
Int ret = 0;
If (null = tda7415_data)
{
Return-enomem;
}
Printk ("Debug at func % s (), line % d by Tongjiang/N" ,__ function __,__ line __);
Tda7415_data-> audio7415_regbuf [0] = 0xff;
Tda7415_data-> audio7415_regbuf [1] = 0xd0;
Tda7415_data-> audio7415_regbuf [2] = 0xfe; // Bass: 40Hz
Tda7415_data-> audio7415_regbuf [3] = 0xff;
Tda7415_data-> audio7415_regbuf [4] = 0xff;
Tda7415_data-> audio7415_regbuf [5] = 0xfe;
Tda7415_data-> audio7415_regbuf [6] = 0xff; // full mute
Tda7415_data-> audio7415_regbuf [7] = 0xff; // full mute
Tda7415_data-> audio7415_regbuf [8] = 0xff; // full mute
Tda7415_data-> audio7415_regbuf [9] = 0x30; // fast charge: Must be setting release
Tda7415_data-> audio7415_regbuf [10] = 0x7c;
Tda7415_data-> audio7415_regbuf [11] = 0xec; // center, subwoof of the mix channel from AC3; jowen. xiao091112
Tda7415_data-> audio7415_regbuf [12] = 0x76; // left & right channel high Filter Bypass
Tda7415_data-> audio7415_regbuf [13] = 0x70;
Tda7415_data-> audio7415_regbuf [14] = 0x70;
Tda7415_data-> audio7415_regbuf [15] = 0x70;
Tda7415_data-> audio7415_regbuf [16] = 0x70;
Tda7415_data-> audio7415_regbuf [17] = 0xf6; // stereo Bypass
Tda7415_data-> audio7415_regbuf [18] = 0x70;
Tda7415_data-> audio7415_regbuf [19] = 0x70;
Tda7415_data-> audio7415_regbuf [20] = 0xfe;
Tda7415_data-> audio7415_regbuf [21] = 0xc8;
Tda7415_data-> audio7415_regbuf [22] = 0xf6; // y11110110; // sotf-Mute time 5 ms, soft-step 2.56 Ms
Tda7415_data-> audio7415_regbuf [23] = 0xf1;
Memset (& tda7415_data-> audio7415.curr _ CH, 0, sizeof (audio7415struct ));
Tda7415_data-> audio7415.bas = 0;
Tda7415_data-> audio7415.tre = 0;
Tda7415_data-> audio7415.mid = 0;
Tda7415_data-> audio7415.balance = 0;
Tda7415_data-> audio7415.fader = 0;
Tda7415_data-> audio7415.subwoof = 0;
Tda7415_data-> audio7415.center = 0;
Reg = 0x5f;
Data = 0x3e;
Ret = tda7415_reg_write (client, Reg, data );
Printk ("Initial write of tda7415 write over ret = % d/N", RET );
/*
For (I = 0; I <array_size (tda7415_data-> audio7415_regcache); I ++)
{
Int v = i2c_smbus_read_byte_data (client, I );
If (v <0)
{
Return-enodev;
}
Tda7415_data-> audio7415_regcache [I] = V;
}
For (I = 0; I <array_size (tda7415_data-> audio7415_regcache); I ++)
{
Printk ("Debug read byte 0 is % d", tda7415_data-> audio7415_regcache [I]);
}
*/
Return 0;
}