I'm curious about the headphone feature of bela.

I see that the level is available in the command-line settings and it looks like you just use the main outs for headphones.. but I wonder how that interacts with the dac level and the pga level?

hardware explained link for reference.

The block diagram for the audio codec in use can be found in the tlv320aic3104 datasheet, page 18.

There is an analog attenuator at the far left of the diagram. Multiple inputs can be summed together before the ADC, each with its own attenuation. Only one input per ADC is connected on the Bela board. The --adc-level sets this attenuation and defaults to 0. Unless your signal is too hot and the PGA is already at 0, I see no reason why you would want to change this.

The PGA is the programmable-gain-amplifier, that is a digitally-controlled analog preamplifier that is situated at the input stage, after the attenuator and before the ADC.
This is set with --pga-gain-left and --pga-gain-right.

The "AGC" is "automatic-gain-control", basically a limiter which acts on the PGA, so in practice it is a digital-sidechain analog compressor. This is not enabled by default on Bela and currently not accessible through the API.

The DAC has its own volume control, which is a digital attenuation before the conversion, set with --dac-level. Again this defaults to 0 and there should be no reason why you'll want to change it.

The output from the DAC (affected from all the above) is then sent in parallel to:
- headphone output. This has an additional analog attenuator control (set by --hp-level). The output that comes from the on-board "audio out" connector comes from here.
- line output. This is available from the J10 non-populated header on the board, where you can solder your own wires if you do not need the headphone output and want a slightly cleaner output signal. This is also sent with no further level control to the on-board power amplifier for connecting passive speakers (note: this power amplifier is not part of the tlv320aic3104 so you do not see it there).

To briefly address your question directly, PGA controls the input gain, DAC level should be left to the default value of 0 and headphone output affects your output level through the on-board audio output, but not the line out or the speaker out.

Please can you explain in more detail how to get the line out from J10 on the board?
Just solder to the headers labelled L&R? Is one of the headers there connected to ground?

Yes, L and R on J9 or J10 will do the job. There is no ground available there, but you can get one from J1 (which consists of two unpopulated through-holes). Note that the pads labelled L and R on J9 are the "hot" and the pads between them are the L and R "cold" (for balanced line output), again you can compare the pinout in the datasheet at pages 3/4 and the board diagram.

Please can you link to the datasheet and diagram you are referring to?
Thanks!

Ah I see J1 on the Bela pin diagram. So both those holes are linked to ground? Or one of them? I guess I am missing some documentation!

Links to the board diagram and the datasheet are in my first post here. J1 has two pins, one is 5V and one is ground. They are appropriately labelled on the board.