For the benefit of those working with the TLV320AIC3204 CODEC, I release this *very experimental* and incomplete driver to hopefully encourage further work. I haven't made it available as a patch; rather just attached the driver and its header file, since the driver is far from complete. These files go in sound/soc/codecs, with appropriate entries into Kconfig and Makefile.
Presently, I'm working on defining all the registers, and considering methods for allowing their configuration via the APIs available.
The TLV320AIC3204 CODEC exposes its registers in individual "pages"; the first register (reg 0) is the page select register, the remaining registers change in meaning depending on what page is selected. In the CODEC driver, I therefore use a 16-bit addressing scheme, whereby the upper 8-bits indicates the page number, and the lower 8-bits is the actual register address used. Page select is *always* at register 0x0000 in cache. When a register on a different page is accessed, the page is switched first before accessing the register. I'm not certain if this is the best approach; but it was the only way that made sense.
The CODEC driver claims total control of the I2C device, and therefore makes it impossible to alter registers using i2c-tools. However, as a work-around; I have provided read/write access to the registers via sysfs... we use the AIC3204 attached to I2C bus 0; the CODEC therefore lives under:
/sys/bus/i2c/devices/0-0018
There are two files: - regsel: Takes or reports back the 16-bit register address in hexadecimal - regdata: Reads or writes the value of the register
`i2cget -y 0 0x18` and `i2cset -y 0 0x18` can be replaced by the following shell functions:
acget () { printf "0x%02x%02x\n" $1 > /sys/bus/i2c/devices/0-0018/regsel cat /sys/bus/i2c/devices/0-0018/regdata }
acset () { printf "0x%02x%02x\n" $1 > /sys/bus/i2c/devices/0-0018/regsel printf "0x%02x\n" $2 > /sys/bus/i2c/devices/0-0018/regdata }
At most, to get sound out, you may need to use the above two functions to set your routing and levels. Register dumps can also be done using shell scripting, although it's slower than the i2cdump tool.
Other things that need work; - PLL support doesn't seem to work ... this will need adjustment - Sample rates are "off"... 48kHz audio gets played at ~52kHz for example (see above comment about PLL) - Routing is hard-coded at present - In my testing, sound output is low in amplitude
I hope to address some of these over this week, but in the meantime I'll provide my work in its current form in the hope that we can build upon this and improve it for inclusion in the Linux kernel.