diff -u -r vdr-1.3.20/config.c vdr-1.3.20-lnbshare/config.c
--- vdr-1.3.20/config.c	2005-02-05 11:43:04.000000000 +0100
+++ vdr-1.3.20-lnbshare/config.c	2005-02-08 19:17:44.000000000 +0100
@@ -300,6 +300,11 @@
   CurrentChannel = -1;
   CurrentVolume = MAXVOLUME;
   CurrentDolby = 0;
+
+//ML
+  for (int i = 0; i < MAXDEVICES; i++) CardUsesLNBnr[i] = i + 1;
+//ML-Ende
+ 
 }
 
 cSetup& cSetup::operator= (const cSetup &s)
@@ -457,7 +462,22 @@
   else if (!strcasecmp(Name, "CurrentVolume"))       CurrentVolume      = atoi(Value);
   else if (!strcasecmp(Name, "CurrentDolby"))        CurrentDolby       = atoi(Value);
   else
-     return false;
+
+//ML
+  {
+    char tmp[20];
+    bool result = false;
+    for (int i = 1; i <= MAXDEVICES; i++) {
+      sprintf(tmp, "Card%dusesLNBnr", i);
+      if (!strcasecmp(Name, tmp)) {
+        CardUsesLNBnr[i - 1] = atoi(Value);
+        result = true;
+      }   
+    }
+     return result;
+  }
+//ML-Ende
+
   return true;
 }
 
@@ -520,6 +540,16 @@
   Store("CurrentVolume",      CurrentVolume);
   Store("CurrentDolby",       CurrentDolby);
 
+//ML
+  char tmp[20];
+  if (cDevice::NumDevices() > 1) {
+     for (int i = 1; i <= cDevice::NumDevices(); i++) {
+        sprintf(tmp, "Card%dusesLNBnr", i);
+        Store(tmp, CardUsesLNBnr[i - 1]);
+     }
+  }
+//ML-Ende
+
   Sort();
 
   if (cConfig<cSetupLine>::Save()) {
diff -u -r vdr-1.3.20/config.h vdr-1.3.20-lnbshare/config.h
--- vdr-1.3.20/config.h	2005-02-05 11:43:22.000000000 +0100
+++ vdr-1.3.20-lnbshare/config.h	2005-02-08 19:17:44.000000000 +0100
@@ -254,6 +254,11 @@
   int CurrentChannel;
   int CurrentVolume;
   int CurrentDolby;
+
+//ML
+  int CardUsesLNBnr[MAXDEVICES - 1];
+//ML-Ende
+
   int __EndData__;
   cSetup(void);
   cSetup& operator= (const cSetup &s);
diff -u -r vdr-1.3.20/device.c vdr-1.3.20-lnbshare/device.c
--- vdr-1.3.20/device.c	2005-02-06 15:10:37.000000000 +0100
+++ vdr-1.3.20-lnbshare/device.c	2005-02-20 19:28:08.000000000 +0100
@@ -19,6 +19,10 @@
 #include "status.h"
 #include "transfer.h"
 
+//ML
+#include "diseqc.h"
+//ML-Ende
+
 // --- cPesAssembler ---------------------------------------------------------
 
 class cPesAssembler {
@@ -154,6 +158,12 @@
 
   SetVideoFormat(Setup.VideoFormat);
 
+//ML
+  LNBstate = -1;
+  LNBnr = Setup.CardUsesLNBnr[cardIndex];
+  LNBsource = NULL;
+//ML-Ende
+
   active = false;
 
   mute = false;
@@ -201,6 +211,16 @@
      useDevice |= (1 << n);
 }
 
+//ML
+void cDevice::SetLNBnr(void)
+{
+  for (int i = 0; i < numDevices; i++) {
+    device[i]->LNBnr = Setup.CardUsesLNBnr[i];
+    isyslog("setting device %d to use LNB %d", i, device[i]->LNBnr);
+  }
+}
+//ML-Ende
+
 int cDevice::NextCardIndex(int n)
 {
   if (n > 0) {
@@ -264,14 +284,124 @@
   return (0 <= Index && Index < numDevices) ? device[Index] : NULL;
 }
 
+
+//ML
+cDevice *cDevice::GetBadDevice(const cChannel *Channel)
+{
+
+if (Setup.DiSEqC) {
+  int *diseqc; 
+  diseqc = (int*) Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization());
+
+//    isyslog("diseq %d to use LNB %d", (int) diseqc, LNBnr);
+  for (int i = 0; i < numDevices; i++) {
+    if (this != device[i] && device[i]->GetLNBnr() == LNBnr && device[i]->GetLNBsource() != diseqc) {
+      return device[i];
+    }
+  }
+  return NULL;
+
+} else {
+
+char requiredState;
+
+  if (Channel->Frequency() >= Setup.LnbSLOF) {
+    requiredState = 1 ;
+  } else {
+    requiredState = 0;
+  }
+  if (Channel->Polarization() == 'v' || Channel->Polarization() == 'V') requiredState += 2;
+ 
+  for (int i = 0; i < numDevices; i++) {
+    if (this != device[i] && device[i]->GetLNBnr() == LNBnr && device[i]->GetLNBconf() != requiredState) {
+      return device[i];
+    }
+  }
+  return NULL;
+}
+}
+
+int cDevice::GetMaxBadPriority(const cChannel *Channel)
+{
+bool PrimaryIsBad = false;
+int maxBadPriority = -2;
+
+if (Setup.DiSEqC) {
+//  cDiseqc *diseqc; 
+  int *diseqc; 
+  diseqc = (int*) Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization());
+
+  for (int i = 0; i < numDevices; i++) {
+    if (this != device[i] && device[i]->GetLNBnr() == LNBnr && device[i]->GetLNBsource() != diseqc) {
+      if (device[i]->Receiving() && device[i]->Priority() > maxBadPriority) {
+        maxBadPriority = device[i]->Priority();
+      }
+      if (device[i]->IsPrimaryDevice()) {
+          PrimaryIsBad = true;
+      }
+    }
+  }
+  if (PrimaryIsBad) {
+    if (maxBadPriority == -2) {
+      maxBadPriority = -1;
+    } else if (maxBadPriority < Setup.PrimaryLimit) {
+      maxBadPriority = Setup.PrimaryLimit;
+    }
+  }
+  return maxBadPriority;
+
+} else {
+
+char requiredState;
+  if (Channel->Frequency() >= Setup.LnbSLOF) {
+    requiredState = 1 ;
+  } else {
+    requiredState = 0;
+  }
+  if (Channel->Polarization() == 'v' || Channel->Polarization() == 'V') requiredState += 2;
+
+  for (int i = 0; i < numDevices; i++) {
+    if (this != device[i] && device[i]->GetLNBnr() == LNBnr && device[i]->GetLNBconf() != requiredState) {
+      if (device[i]->Receiving() && device[i]->Priority() > maxBadPriority) {
+        maxBadPriority = device[i]->Priority();
+      }
+      if (device[i]->IsPrimaryDevice()) {
+          PrimaryIsBad = true;
+      }
+    }
+  }
+  if (PrimaryIsBad) {
+    if (maxBadPriority == -2) {
+      maxBadPriority = -1;
+    } else if (maxBadPriority < Setup.PrimaryLimit) {
+      maxBadPriority = Setup.PrimaryLimit;
+    }
+  }
+  return maxBadPriority;
+}
+}
+//ML-Ende
+
 cDevice *cDevice::GetDevice(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers)
 {
   cDevice *d = NULL;
-  int select = 7, pri;
+
+//ML
+  int select = 11, pri, pri2, badPriority;
+//ML-Ende
 
   for (int i = 0; i < numDevices; i++) {
       bool ndr;
       if (device[i]->ProvidesChannel(Channel, Priority, &ndr)) { // this device is basicly able to do the job
+
+//ML
+         badPriority = device[i]->GetMaxBadPriority(Channel);
+         if (badPriority >= Priority || (badPriority == -1 && Priority < Setup.PrimaryLimit)) continue;
+         if (badPriority == -2) pri2 = 0;
+         else if (badPriority == -1) pri2 = 2;
+         else pri2 = 4; 
+//ML-Ende
+
          if (device[i]->Receiving() && !ndr)
             pri = 0; // receiving and allows additional receivers
          else if (d && !device[i]->Receiving() && device[i]->ProvidesCa(Channel) < d->ProvidesCa(Channel))
@@ -286,8 +416,12 @@
             pri = 5; // receiving with same priority but fewer Ca's
          else
             pri = 6; // all others
-         if (pri < select) {
-            select = pri;
+
+//ML
+         if (pri + pri2 < select) {
+            select = pri + pri2;
+//ML-Ende
+
             d = device[i];
             if (NeedsDetachReceivers)
                *NeedsDetachReceivers = ndr;
@@ -481,9 +615,24 @@
 
 bool cDevice::SwitchChannel(const cChannel *Channel, bool LiveView)
 {
+//ML
+  cDevice *tmpDevice;
+  if (this->GetMaxBadPriority(Channel) >= 0) {
+     Skins.Message(mtInfo, tr("Channel locked by LNB!"));
+     return false;
+  }
+  while ((tmpDevice = GetBadDevice(Channel)) != NULL) {
+    if (tmpDevice->IsPrimaryDevice() )
+      tmpDevice->SwitchChannelForced(Channel, true);
+    else
+      tmpDevice->SwitchChannelForced(Channel, false);
+  }
+//ML-Ende
+
   if (LiveView)
      isyslog("switching to channel %d", Channel->Number());
   for (int i = 3; i--;) {
+
       switch (SetChannel(Channel, LiveView)) {
         case scrOk:           return true;
         case scrNotAvailable: Skins.Message(mtInfo, tr("Channel not available!"));
@@ -497,6 +646,27 @@
   return false;
 }
 
+//ML
+bool cDevice::SwitchChannelForced(const cChannel *Channel, bool LiveView)
+{
+  if (LiveView)
+     isyslog("switching to channel %d", Channel->Number());
+  for (int i = 3; i--;) {
+      switch (SetChannel(Channel, LiveView)) {
+        case scrOk:           return true;
+        case scrNotAvailable: Skins.Message(mtInfo, tr("Channel not available!"));
+                              return false;
+        case scrNoTransfer:   Skins.Message(mtError, tr("Can't start Transfer Mode!"));
+                              return false;
+        case scrFailed:       break; // loop will retry
+        }
+      esyslog("retrying");
+      }
+  return false;
+}
+//ML-Ende
+
+
 bool cDevice::SwitchChannel(int Direction)
 {
   bool result = false;
@@ -507,7 +677,10 @@
      cChannel *channel;
      while ((channel = Channels.GetByNumber(n, Direction)) != NULL) {
            // try only channels which are currently available
-           if (PrimaryDevice()->ProvidesChannel(channel, Setup.PrimaryLimit) || PrimaryDevice()->CanReplay() && GetDevice(channel, 0))
+//ML
+           if (PrimaryDevice()->GetMaxBadPriority(channel) < 0 && (PrimaryDevice()->ProvidesChannel(channel, Setup.PrimaryLimit) || PrimaryDevice()->CanReplay() && GetDevice(channel, 0)))
+//ML-Ende
+
               break;
            n = channel->Number() + Direction;
            }
@@ -541,9 +714,35 @@
   // If this DVB card can't receive this channel, let's see if we can
   // use the card that actually can receive it and transfer data from there:
 
+//ML
+  char requiredState;
+  if (Channel->Frequency() >= Setup.LnbSLOF) {
+    requiredState = 1;
+  } else {
+    requiredState = 0;
+  }
+  if (Channel->Polarization() == 'v' || Channel->Polarization() == 'V') requiredState += 2;
+//ML-Ende
+
   if (NeedsTransferMode) {
      cDevice *CaDevice = GetDevice(Channel, 0);
      if (CaDevice && CanReplay()) {
+
+//ML
+       if (CaDevice->GetLNBnr() == LNBnr) {
+         if (LNBstate != requiredState || (Setup.DiSEqC && LNBsource != (int*) Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization())) ) {
+           if (IsPrimaryDevice()) {
+             SetChannelDevice(Channel, true);
+           } else {
+             SetChannelDevice(Channel, false);
+           }
+         LNBstate = requiredState;
+         LNBsource = (int*) Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization());
+//    isyslog("setting device XXXX");
+         }
+       }
+//ML-Ende
+
         cStatus::MsgChannelSwitch(this, 0); // only report status if we are actually going to switch the channel
         if (CaDevice->SetChannel(Channel, false) == scrOk) // calling SetChannel() directly, not SwitchChannel()!
            cControl::Launch(new cTransferControl(CaDevice, Channel->Vpid(), Channel->Apids(), Channel->Dpids(), Channel->Spids()));
@@ -561,6 +760,13 @@
         sectionHandler->SetStatus(false);
         sectionHandler->SetChannel(NULL);
         }
+
+//ML
+     LNBstate = requiredState;
+     LNBsource = (int*) Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization());
+//    isyslog("setting device AAAA");
+//ML-Ende
+
      if (SetChannelDevice(Channel, LiveView)) {
         // Start section handling:
         if (sectionHandler) {
diff -u -r vdr-1.3.20/device.h vdr-1.3.20-lnbshare/device.h
--- vdr-1.3.20/device.h	2005-02-06 12:43:04.000000000 +0100
+++ vdr-1.3.20-lnbshare/device.h	2005-02-20 18:13:42.000000000 +0100
@@ -21,6 +21,13 @@
 #include "thread.h"
 #include "tools.h"
 
+//ML
+//#include "config.h"
+//#include "diseqc.h"
+//#include "sources.h"
+//extern cDiseqcs Diseqcs;
+//ML-Ende
+
 #define MAXDEVICES         16 // the maximum number of devices in the system
 #define MAXPIDHANDLES      64 // the maximum number of different PIDs per device
 #define MAXRECEIVERS       16 // the maximum number of receivers per device
@@ -122,6 +129,25 @@
          ///< given Priority.
          ///< See ProvidesChannel() for more information on how
          ///< priorities are handled, and the meaning of NeedsDetachReceivers.
+
+//ML
+private:
+  char LNBstate;  // Frequenzband und Polarisation des DVB-Empfängers
+//  cDiseqc *LNBsource;  // [DiSEqC] Empfangsquelle
+  int *LNBsource;  // [DiSEqC] Empfangsquelle
+
+  int LNBnr;      // Nummer des genutzten LNB
+public:
+  char GetLNBconf(void) { return LNBstate; }
+  int *GetLNBsource(void) { return LNBsource; }
+  int GetLNBnr(void) { return LNBnr; }
+  static void SetLNBnr(void);
+  cDevice *GetBadDevice(const cChannel *Channel);
+         // Gibt ggf. eine DVB-Karte zurück, die sich mit dieser Karte den LNB teilt und deren Konfiguration unverträglich ist.
+  int GetMaxBadPriority(const cChannel *Channel);
+         // Gibt die höchte Priorität aller Aufträge/Aufnahmen mit unverträglicher LNB Konfiguration zurück.
+//ML-Ende
+
   static void Shutdown(void);
          ///< Closes down all devices.
          ///< Must be called at the end of the program.
@@ -199,6 +225,13 @@
   bool SwitchChannel(const cChannel *Channel, bool LiveView);
          ///< Switches the device to the given Channel, initiating transfer mode
          ///< if necessary.
+
+//ML
+  bool SwitchChannelForced(const cChannel *Channel, bool LiveView);
+         ///< Switches the device to the given Channel, initiating transfer mode
+         ///< if necessary. Forces the switch without taking care of the LNB configuration.
+//ML-Ende
+
   static bool SwitchChannel(int Direction);
          ///< Switches the primary device to the next available channel in the given
          ///< Direction (only the sign of Direction is evaluated, positive values
diff -u -r vdr-1.3.20/diseqc.h vdr-1.3.20-lnbshare/diseqc.h
--- vdr-1.3.20/diseqc.h	2002-12-07 14:54:02.000000000 +0100
+++ vdr-1.3.20-lnbshare/diseqc.h	2005-02-18 22:51:42.000000000 +0100
@@ -56,7 +56,10 @@
   uchar *Codes(int &NumCodes) { NumCodes = numCodes; return numCodes ? codes : NULL; }
   };
 
+
+//ML
 class cDiseqcs : public cConfig<cDiseqc> {
+//class cDiseqcs : public cDiseqc {
 public:
   cDiseqc *Get(int Source, int Frequency, char Polarization);
   };
diff -u -r vdr-1.3.20/eitscan.c vdr-1.3.20-lnbshare/eitscan.c
--- vdr-1.3.20/eitscan.c	2004-10-31 17:19:49.000000000 +0100
+++ vdr-1.3.20-lnbshare/eitscan.c	2005-02-12 18:08:34.000000000 +0100
@@ -149,7 +149,11 @@
                             if (!(Device->Receiving(true) || Device->Replaying())) {
                                const cChannel *Channel = ScanData->GetChannel();
                                if (Channel) {
-                                  if ((!Channel->Ca() || Channel->Ca() == Device->DeviceNumber() + 1 || Channel->Ca() >= 0x0100) && Device->ProvidesTransponder(Channel)) {
+
+//ML
+                                  if ((!Channel->Ca() || Channel->Ca() == Device->DeviceNumber() + 1 || Channel->Ca() >= 0x0100) && Device->ProvidesTransponder(Channel) && (!Device->GetBadDevice(Channel) == -1 && Setup.EPGScanTimeout && now - lastActivity > Setup.EPGScanTimeout * 3600) ) {
+//ML-Ende
+
                                      if (Device == cDevice::PrimaryDevice() && !currentChannel) {
                                         currentChannel = Device->CurrentChannel();
                                         Skins.Message(mtInfo, "Starting EPG scan");
diff -u -r vdr-1.3.20/i18n.c vdr-1.3.20-lnbshare/i18n.c
--- vdr-1.3.20/i18n.c	2005-02-05 11:46:30.000000000 +0100
+++ vdr-1.3.20-lnbshare/i18n.c	2005-02-20 19:32:07.000000000 +0100
@@ -5220,6 +5220,52 @@
     "ST:TNG konsool",
     "ST:TNG konsol",
   },
+
+//ML
+  { "Channel locked by LNB!",
+    "Kanal durch LNB gesperrt!",
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "Chaîne interdite par la LNB",
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+  },
+  { "Setup.LNB$DVB device %d uses LNB No.",
+    "DVB-Empfänger %d nutzt LNB Nr.",
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "La carte DVB %d utilise la LNB No.",
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+    "",// TODO
+  },
+//ML
+
   { NULL }
   };
 
@@ -5357,3 +5403,4 @@
      }
   return false;
 }
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
\ Kein Zeilenumbruch am Dateiende.
diff -u -r vdr-1.3.20/menu.c vdr-1.3.20-lnbshare/menu.c
--- vdr-1.3.20/menu.c	2005-02-06 12:33:13.000000000 +0100
+++ vdr-1.3.20-lnbshare/menu.c	2005-02-13 23:08:50.000000000 +0100
@@ -2012,6 +2012,16 @@
 
   Clear();
 
+//ML
+  char tmp[30];
+  if (cDevice::NumDevices() > 1) {
+     for (int i = 1; i <= cDevice::NumDevices(); i++) {
+        sprintf( tmp, tr("Setup.LNB$DVB device %d uses LNB No."), i);
+        Add(new cMenuEditIntItem( tmp, &data.CardUsesLNBnr[i - 1], 1, cDevice::NumDevices() ));
+     }
+  }
+//ML-Ende
+
   Add(new cMenuEditBoolItem(tr("Setup.LNB$Use DiSEqC"),               &data.DiSEqC));
   if (!data.DiSEqC) {
      Add(new cMenuEditIntItem( tr("Setup.LNB$SLOF (MHz)"),               &data.LnbSLOF));
@@ -2028,6 +2038,10 @@
   int oldDiSEqC = data.DiSEqC;
   eOSState state = cMenuSetupBase::ProcessKey(Key);
 
+//ML
+  if (Key == kOk) cDevice::SetLNBnr();
+//ML-Ende
+
   if (Key != kNone && data.DiSEqC != oldDiSEqC)
      Setup();
   return state;
@@ -3112,6 +3126,21 @@
      int Priority = Timer ? Timer->Priority() : Pause ? Setup.PausePriority : Setup.DefaultPriority;
      cDevice *device = cDevice::GetDevice(channel, Priority, &NeedsDetachReceivers);
      if (device) {
+
+//ML
+       cDevice *tmpDevice;
+       while ((tmpDevice = device->GetBadDevice(channel))) {
+         if (tmpDevice->Replaying() == false) {
+           Stop(tmpDevice);
+           if (tmpDevice->IsPrimaryDevice() )
+             tmpDevice->SwitchChannelForced(channel, true);
+           else
+             tmpDevice->SwitchChannelForced(channel, false);
+         } else
+		 tmpDevice->SwitchChannelForced(channel, false);
+	   }
+//ML-Ende
+
         if (NeedsDetachReceivers) {
            Stop(device);
            if (device == cTransferControl::ReceiverDevice())
