diff -Nu vdr-original/alsa_spdif.c vdr-1.4.4/alsa_spdif.c
--- vdr-original/alsa_spdif.c	1970-01-01 01:00:00.000000000 +0100
+++ vdr-1.4.4/alsa_spdif.c	2007-01-31 16:44:50.000000000 +0100
@@ -0,0 +1,84 @@
+#include "alsa_spdif.h"
+
+alsa_volume::alsa_volume()
+{
+	strcpy(card,"default");			// change it if you need
+	blocked=0;
+	snd_ctl_elem_id_alloca(&iSpdif);
+	snd_ctl_elem_id_alloca(&iWave);
+	snd_ctl_elem_id_alloca(&iSurr);
+	snd_ctl_elem_value_alloca(&controlSp);
+	snd_ctl_elem_value_alloca(&controlWv);
+	snd_ctl_elem_value_alloca(&controlSr);
+	snd_ctl_elem_id_set_interface(iSpdif, SND_CTL_ELEM_IFACE_MIXER);
+	snd_ctl_elem_id_set_interface(iWave, SND_CTL_ELEM_IFACE_MIXER);
+	snd_ctl_elem_id_set_interface(iSurr, SND_CTL_ELEM_IFACE_MIXER);
+	/* below i am using numid 20 for 'IEC958 Optical Playback Volume'
+	   on my SBLive!, while numid 17 is for:
+	   'IEC958 TTL Playback Volume'
+	   you can obtain it all using 'amixer controls' */
+	snd_ctl_elem_id_set_numid(iSpdif, 20);	//'IEC TTL Playback Volume'
+	snd_ctl_elem_id_set_numid(iWave, 1);	//'Wave Playboack Volume'
+	snd_ctl_elem_id_set_numid(iSurr, 2);	//'Wave Surround Playback Volume'
+	if ((err = snd_ctl_open(&handle, card, 0)) < 0)
+	{
+		esyslog("alsa_spdif: ALSA %s card open error: %s\n", card, snd_strerror(err));
+		blocked=1;
+	}
+	else
+		esyslog("alsa_spdif: ALSA %s card opened\n", card);
+	if (!blocked)
+	{
+	    snd_ctl_elem_value_set_id(controlSp, iSpdif);
+	    snd_ctl_elem_value_set_id(controlWv, iWave);
+	    snd_ctl_elem_value_set_id(controlSr, iSurr);
+	}
+}
+
+alsa_volume::~alsa_volume()
+{
+	if (!blocked)
+	    snd_ctl_close(handle);
+	esyslog("alsa_spdif: closing ALSA %s card\n", card);
+}
+
+void alsa_volume::spdif(int Volume)
+{
+	if (blocked)
+	    return;
+
+	snd_ctl_elem_value_set_integer(controlSp, 0, Volume);	//left channel
+	snd_ctl_elem_value_set_integer(controlSp, 1, Volume);	//right channel
+
+	if ((err = snd_ctl_elem_write(handle, controlSp)) < 0)
+		esyslog("alsa_spdif: ALSA %s card element write error: %s\n", card, snd_strerror(err));
+#ifdef DEBUG
+	else
+		printf("alsa_spdif: ALSA %s card element write SPDIF volume: %d\n", card, Volume);
+#endif
+}
+
+void alsa_volume::wave(int Volume)
+{
+	if (blocked)
+	    return;
+
+	snd_ctl_elem_value_set_integer(controlWv, 0, Volume);	//left channel
+	snd_ctl_elem_value_set_integer(controlWv, 1, Volume);	//right channel
+
+	snd_ctl_elem_value_set_integer(controlSr, 0, Volume);	//left channel
+	snd_ctl_elem_value_set_integer(controlSr, 1, Volume);	//right channel
+
+	if ((err = snd_ctl_elem_write(handle, controlWv)) < 0)
+		esyslog("alsa_spdif: ALSA %s card element write error: %s\n", card, snd_strerror(err));
+#ifdef DEBUG
+	else
+		printf("alsa_spdif: ALSA %s card element write Wave volume: %d\n", card, Volume);
+#endif
+	if ((err = snd_ctl_elem_write(handle, controlSr)) < 0)
+		esyslog("alsa_spdif: ALSA %s card element write error: %s\n", card, snd_strerror(err));
+#ifdef DEBUG
+	else
+		printf("alsa_spdif: ALSA %s card element write WaveSurround volume: %d\n", card, Volume);
+#endif
+}
diff -Nu vdr-original/alsa_spdif.h vdr-1.4.4/alsa_spdif.h
--- vdr-original/alsa_spdif.h	1970-01-01 01:00:00.000000000 +0100
+++ vdr-1.4.4/alsa_spdif.h	2007-01-31 16:55:34.000000000 +0100
@@ -0,0 +1,24 @@
+#ifndef __ALSA_SPDIF
+#define __ALSA_SPDIF
+
+#include "tools.h"
+#include <string.h>
+#include <alsa/asoundlib.h>
+
+class alsa_volume
+{
+    private:
+	char card[64];
+	int err;
+	bool blocked;
+	snd_ctl_t *handle;
+	snd_ctl_elem_id_t *iSpdif, *iWave, *iSurr;
+	snd_ctl_elem_value_t *controlSp, *controlWv, *controlSr;
+    public:
+	void spdif(int);
+	void wave(int);
+	alsa_volume();
+	~alsa_volume();
+};
+
+#endif //__ALSA_SPDIF
diff -Nu vdr-original/dvbdevice.c vdr-1.4.4/dvbdevice.c
--- vdr-original/dvbdevice.c	2006-11-21 09:47:18.000000000 +0100
+++ vdr-1.4.4/dvbdevice.c	2007-01-31 16:54:26.000000000 +0100
@@ -26,6 +26,10 @@
 #include "status.h"
 #include "transfer.h"
 
+#if defined(SPDIF)
+alsa_volume *alsa_vol=NULL;
+#endif
+
 #define DO_REC_AND_PLAY_ON_PRIMARY_DEVICE 1
 #define DO_MULTIPLE_RECORDINGS 1
 //#define DO_MULTIPLE_CA_CHANNELS
@@ -59,6 +63,10 @@
 
 static int DvbOpen(const char *Name, int n, int Mode, bool ReportError = false)
 {
+#if defined(SPDIF)
+  if (alsa_vol==NULL)
+     alsa_vol=new alsa_volume();
+#endif
   const char *FileName = *cDvbName(Name, n);
   int fd = open(FileName, Mode);
   if (fd < 0 && ReportError)
@@ -434,6 +442,10 @@
 
 cDvbDevice::~cDvbDevice()
 {
+#if defined(SPDIF)
+  if (alsa_vol)
+     delete alsa_vol;
+#endif
   delete spuDecoder;
   delete dvbTuner;
   // We're not explicitly closing any device files here, since this sometimes
@@ -936,10 +948,14 @@
   if (HasDecoder()) {
      if (digitalAudio)
         Volume = 0;
+#if defined(SPDIF)
+     alsa_vol->spdif((Volume*100)/255);
+#else
      audio_mixer_t am;
      // conversion for linear volume response:
      am.volume_left = am.volume_right = 2 * Volume - Volume * Volume / 255;
      CHECK(ioctl(fd_audio, AUDIO_SET_MIXER, &am));
+#endif
      }
 }
 
diff -Nu vdr-original/dvbdevice.h vdr-1.4.4/dvbdevice.h
--- vdr-original/dvbdevice.h	2006-05-28 17:05:19.000000000 +0200
+++ vdr-1.4.4/dvbdevice.h	2007-01-31 16:44:50.000000000 +0100
@@ -15,6 +15,10 @@
 #include "device.h"
 #include "dvbspu.h"
 
+#if defined(SPDIF)
+#include "alsa_spdif.h"
+#endif
+
 #if DVB_API_VERSION != 3
 #error VDR requires Linux DVB driver API version 3!
 #endif
diff -Nu vdr-original/Makefile vdr-1.4.4/Makefile
--- vdr-original/Makefile	2006-08-20 12:44:22.000000000 +0200
+++ vdr-1.4.4/Makefile	2007-02-07 20:28:22.000000000 +0100
@@ -18,6 +18,9 @@
 MANDIR   = /usr/local/man
 BINDIR   = /usr/local/bin
 LIBS     = -ljpeg -lpthread -ldl -lcap
+ifdef SPDIF
+    LIBS     += -lasound
+endif
 INCLUDES =
 
 PLUGINDIR= ./PLUGINS
@@ -38,6 +41,9 @@
        receiver.o recorder.o recording.o remote.o remux.o ringbuffer.o sdt.o sections.o\
        skinclassic.o skins.o skinsttng.o sources.o spu.o status.o svdrp.o themes.o thread.o\
        timers.o tools.o transfer.o vdr.o videodir.o
+ifdef SPDIF
+OBJS += alsa_spdif.o
+endif
 
 FIXFONT_ISO8859_1 = -adobe-courier-bold-r-normal--25-*-100-100-m-*-iso8859-1
 OSDFONT_ISO8859_1 = -adobe-helvetica-medium-r-normal--23-*-100-100-p-*-iso8859-1
@@ -89,6 +95,11 @@
 DEFINES += -DVFAT
 endif
 
+ifdef SPDIF
+# volume control for SPDIF output
+DEFINES += -DSPDIF
+endif
+
 all: vdr
 font: genfontfile\
       fontfix-iso8859-1.c fontosd-iso8859-1.c fontsml-iso8859-1.c\

