I just built a new Ubuntu machine. The sound did not work. I searched these forums, the solutions gave me a headache. Isn't Ubuntu supposed to be easy to configure? I tried the easiest solution first, from the posts from aktiwers, and it really was simple. It took only 3 steps! The hard part was getting through all the verbiage.
Here's how I did it( I'm repeating info from aktiwers, only to make it clearer and simpler and in 1 place):
What I didn't do: I did not download or recompile the latest ALSA. Why bother? It turns out I didn't need to do that, why hassle with it if you don't have to.
Step 1: Applications->Accessories->Terminal. At the prompt paste in:
cat /proc/asound/card0/codec#* | grep Codec
it'll return something like, Codec: Realtek ALC888
Step 2: Go to
http://www.mjmwired.net/kernel/Documentation/sound/alsa/ALSA-Configuration.txt
Find your Codec. There is a list of model name and descriptions for each Codec starting on line number785. Copy the model name you've got. For me it was 6stack-dig.
Step 3: Again at the terminal type sudo gedit /etc/modprobe.d/alsa-base
Provide pw when prompted. Add at the end of file: options snd-hda-intel model=6stack-dig
Of course with your model in place of 6stack-dig. Save the file. That's it!
Now I even have digital sound coming through the spdif:guitar: