[HTC Amaze 4G] dcacklam:
On our phones, and several others, the audio subsystem is made up of several different chips.

The one we (in CM10-land) are most interested in, is the TPA2051, as this is the AMP circuit, that controls volume.

It's run over I2C and configured by a file known as TPA2051_CFG.csv

Other versions of the file are present on the phone, but according to logcat, the CFG.csv version is the one actually 'fed' to the DSP.

The thing is, the format of this file is NOT documented... There is some info out there on the net, but it was written by a non-english-speaker who prefers to tell you to 'google' relevent references on HOW he did what he did.

SO, here we go, on what this file does:

1) Format:

It's a comma-separated-value file (CSV), which will open in Excel if you try to read it on your PC. This makes it into a nice, pretty table-format.

It is formatted by column, as follows:

# Device, Type, Fault Register, Amplifier Control, Auto-Gain Attack, Auto-Gain Release, Mic Gain, Stereo-Out Gain, Headphone Out Gain

HTC Documents the 'Types' and the Device #s in the file.

However they do not document the register-values themselves - perhaps because you can DESTROY your phone's speakers, your headphones, or your ears if you mess them up.

Fortunately, there is a data-sheet, which I have ATTACHED to this post rather than telling you to google it.

In that data sheet, starting on PAGE 16, there are detailed descriptions of the register values.

Register 0 is read-only (it's the way the chip tells you something's broke), 1-6 are writable.

To write a value to the register, you use the tables from the datasheet, and a base-converting calculator (Such as the Windows Calc in 'Programmer mode'.

For each value you want to change, start with the calc in binary, and 'set' the settings you want in that register by using '1' for 'off' and '0' for 'on'.

Then click the 'hex' button to convert to Hex, for placement in the TPA2051_CFG.csv file.

You are going to want to edit the file in Linux, Cygwin, or on the phone over ssh (vi and other editors do not work in adb), because Windows still sticks that stupid ^M on the end of every line...

For example, to set Register 1 to:

'Speaker-Mode Volume Limiter, Volume Limiter Disabled, <Reserved>, Not Shutdown, Headphone Left Off, Headphone Right OFF, Speaker On, No Bypass'

You would enter

10000010

into the calculator

You would then convert it to HEX, which would give you

82

Which is written into the .csv file as 0x82

With that primer, the Page 16 info should be easy to understand.

Note, according to the near-uninteligable original author that cued me in on this, one should not set Stereo Out gain higher than 0x59 and should not set Headphone Out higher than 0x50 or at the extreme 0x55!

0x59 stereo gain formats to:

SPK_Gain: Low (6db)

HDPHN Gain: 0db

<reserved> (Error, should not be set at 0x59 but is in his example)

Stereo Volume (Binary): 11011 (+14dB)

Now, this means that 'Mr Non-English's' recommendation does not quite match up to the docs, as these 0x numbers are HEX ENCODED BINARY (so a bigger HEX may not mean a higher volume), and he sets RESERVED bits... But I'm just sayin... Be careful!