The WM8804 is the S/PDIF transceiver chip of choice for this project. Adding a single line to the Pi's config.txt file, to wit:
is enough to add support for it.
To be compatible with the driver, the chip needs to be configured in software controlled mode, i2c interfacing, the address has to be 0x3b. This is accomplished with pull-up or pull-down resistors on some of the I/O pins of the WM8804. For the driver, there also needs to be a 27 MHz crystal connected. The i2s I/O pins are connected to the relevant pins on the Pi, and the S/PDIF input and output pins connect to TOSLINK input and output modules.
The result of adding the WM8804 chip to the Pi is that it actually becomes the i2s bus master for clocking purposes. This dramatically improves the i2s timing fidelity, as when the Pi is the i2s clock master it winds up generating a lot of jitter because i2s clock frequencies don't divide evenly from the Pi's master clock source.
Of course, instead of optical I/O, you can add the WM8804 chip for timing and hook the i2s bus up to a high quality i2s DAC, like the PCM1793. Personally, I already have a high quality TOSLINK DAC project, which has the benefit of being totally electrically isolated from the Pi.