Ticket #9726: mythtv-0.26-unicable_all_patches_consolidated.3.patch
File mythtv-0.26-unicable_all_patches_consolidated.3.patch, 30.7 KB (added by , 11 years ago) |
---|
-
mythtv/libs/libmythtv/diseqc.cpp
diff -Naur mythtv-0.26-20130424-g5f45c0b-old/mythtv/libs/libmythtv/diseqc.cpp mythtv-0.26-20130424-g5f45c0b-new/mythtv/libs/libmythtv/diseqc.cpp
old new 68 68 #define DISEQC_CMD_WRITE_N0 0x38 69 69 #define DISEQC_CMD_WRITE_N1 0x39 70 70 #define DISEQC_CMD_WRITE_FREQ 0x58 71 #define DISEQC_CMD_ODU 0x5A 72 #define DISEQC_CMD_ODU_MDU 0x5C 71 73 #define DISEQC_CMD_HALT 0x60 72 74 #define DISEQC_CMD_LMT_OFF 0x63 73 75 #define DISEQC_CMD_LMT_E 0x66 … … 85 87 86 88 #define LOC QString("DiSEqCDevTree: ") 87 89 90 bool diseqc_bus_already_reset = false; 91 88 92 QString DiSEqCDevDevice::TableToString(uint type, const TypeTable *table) 89 93 { 90 94 for (; !table->name.isEmpty(); table++) … … 563 567 return lnb; 564 568 } 565 569 570 /** \fn DiSEqCDevTree::FindSCR(const DiSEqCDevSettings&) 571 * \brief Returns the SCR device object selected by the configuration chain. 572 * \param settings Configuration chain in effect. 573 * \return Pointer to SCR object if found, NULL otherwise. 574 */ 575 DiSEqCDevSCR *DiSEqCDevTree::FindSCR(const DiSEqCDevSettings &settings) 576 { 577 DiSEqCDevDevice *node = m_root; 578 DiSEqCDevSCR *scr = NULL; 579 580 while (node) 581 { 582 scr = dynamic_cast<DiSEqCDevSCR*>(node); 583 584 if (scr) 585 break; 586 587 node = node->GetSelectedChild(settings); 588 } 589 590 return scr; 591 } 592 566 593 567 594 /** \fn DiSEqCDevTree::FindDevice(uint) 568 595 * \brief Returns a device by ID. … … 635 662 return false; 636 663 } 637 664 665 bool resend_cmd = false; 666 638 667 #ifndef USING_DVB 639 668 640 669 (void) adr; … … 661 690 662 691 LOG(VB_CHANNEL, LOG_INFO, LOC + "Sending DiSEqC Command: " + cmdstr); 663 692 693 if (repeats >= 10) 694 { 695 repeats = repeats - 10; 696 resend_cmd = true; 697 } 698 664 699 // send the command 665 700 for (uint i = 0; i <= repeats; i++) 666 701 { … … 670 705 return false; 671 706 } 672 707 673 mcmd.msg[0] |= DISEQC_FRM_REPEAT; 708 if (!resend_cmd) 709 mcmd.msg[0] |= DISEQC_FRM_REPEAT; 710 674 711 usleep(DISEQC_SHORT_WAIT); 675 712 } 676 713 … … 684 721 * \param hard_reset If true, the bus will be power cycled. 685 722 * \return True if successful. 686 723 */ 687 bool DiSEqCDevTree::ResetDiseqc(bool hard_reset )724 bool DiSEqCDevTree::ResetDiseqc(bool hard_reset, bool is_SCR) 688 725 { 689 726 Reset(); 690 727 … … 696 733 697 734 SetVoltage(SEC_VOLTAGE_OFF); 698 735 usleep(DISEQC_POWER_OFF_WAIT); 736 diseqc_bus_already_reset = false; 699 737 } 700 738 701 // make sure the bus is powered 702 SetVoltage(SEC_VOLTAGE_18); 703 usleep(DISEQC_POWER_ON_WAIT); 704 // some DiSEqC devices need more time. see #8465 705 usleep(DISEQC_POWER_ON_WAIT); 706 707 // issue a global reset command 708 LOG(VB_CHANNEL, LOG_INFO, LOC + "Resetting DiSEqC Bus"); 709 if (!SendCommand(DISEQC_ADR_ALL, DISEQC_CMD_RESET)) 739 if (!diseqc_bus_already_reset || !is_SCR) 710 740 { 711 LOG(VB_GENERAL, LOG_ERR, LOC + "DiSEqC reset failed" + ENO); 712 return false; 741 // make sure the bus is powered 742 SetVoltage(SEC_VOLTAGE_18); 743 usleep(DISEQC_POWER_ON_WAIT); 744 // some DiSEqC devices need more time. see #8465 745 usleep(DISEQC_POWER_ON_WAIT); 746 747 // issue a global reset command 748 LOG(VB_CHANNEL, LOG_INFO, LOC + "Resetting DiSEqC Bus"); 749 if (!SendCommand(DISEQC_ADR_ALL, DISEQC_CMD_RESET)) 750 { 751 LOG(VB_GENERAL, LOG_ERR, LOC + "DiSEqC reset failed" + ENO); 752 return false; 753 } 754 755 if (is_SCR) 756 diseqc_bus_already_reset = true; 757 } 758 else 759 { 760 LOG(VB_CHANNEL, LOG_INFO, LOC + "Skiping reset: already done for this SCR bus"); 713 761 } 714 762 715 763 usleep(DISEQC_LONG_WAIT); … … 717 765 return true; 718 766 } 719 767 720 void DiSEqCDevTree::Open(int fd_frontend )768 void DiSEqCDevTree::Open(int fd_frontend, bool is_SCR) 721 769 { 722 770 m_fd_frontend = fd_frontend; 723 771 724 772 // issue reset command 725 ResetDiseqc(false /* do a soft reset */);773 ResetDiseqc(false, is_SCR); 726 774 } 727 775 728 776 bool DiSEqCDevTree::SetVoltage(uint voltage) … … 784 832 * \brief Represents a node in a DVB-S device network. 785 833 */ 786 834 787 const DiSEqCDevDevice::TypeTable DiSEqCDevDevice::dvbdev_lookup[ 4] =835 const DiSEqCDevDevice::TypeTable DiSEqCDevDevice::dvbdev_lookup[5] = 788 836 { 789 837 { "switch", kTypeSwitch }, 790 838 { "rotor", kTypeRotor }, 839 { "scr", kTypeSCR }, 791 840 { "lnb", kTypeLNB }, 792 841 { QString::null, kTypeLNB }, 793 842 }; … … 891 940 if (node) 892 941 node->SetDescription("Rotor"); 893 942 break; 943 case kTypeSCR: 944 node = new DiSEqCDevSCR(tree, dev_id); 945 if (node) 946 node->SetDescription("Unicable"); 947 break; 894 948 case kTypeLNB: 895 949 node = new DiSEqCDevLNB(tree, dev_id); 896 950 if (node) … … 2052 2106 } 2053 2107 2054 2108 //////////////////////////////////////// 2109 2110 /** \class DiSEqCDevSCR 2111 * \brief Unicable / SCR Class. 2112 */ 2113 2114 const DiSEqCDevDevice::TypeTable DiSEqCDevSCR::SCRPositionTable[3] = 2115 { 2116 { "A", kTypeScrPosA }, 2117 { "B", kTypeScrPosB }, 2118 { QString::null, kTypeScrPosA }, 2119 }; 2120 2121 DiSEqCDevSCR::DiSEqCDevSCR(DiSEqCDevTree &tree, uint devid) 2122 : DiSEqCDevDevice(tree, devid) 2123 , m_scr_userband(0) 2124 , m_scr_frequency(1400) 2125 , m_scr_pin(-1) 2126 , m_child(0) 2127 { 2128 Reset(); 2129 } 2130 2131 DiSEqCDevSCR::~DiSEqCDevSCR() 2132 { 2133 if (m_child) 2134 delete m_child; 2135 } 2136 2137 void DiSEqCDevSCR::Reset(void) 2138 { 2139 if (m_child) 2140 m_child->Reset(); 2141 } 2142 2143 bool DiSEqCDevSCR::Execute(const DiSEqCDevSettings &settings, const DTVMultiplex &tuning) 2144 { 2145 // retrieve LNB info 2146 DiSEqCDevLNB *lnb = m_tree.FindLNB(settings); 2147 if (!lnb) 2148 { 2149 LOG(VB_GENERAL, LOG_ERR, LOC + "SCR: No LNB for this configuration!"); 2150 return false; 2151 } 2152 2153 bool high_band = lnb->IsHighBand(tuning); 2154 bool horizontal = lnb->IsHorizontal(tuning); 2155 uint32_t frequency = lnb->GetIntermediateFrequency(settings, tuning); 2156 uint t = (frequency / 1000 + m_scr_frequency + 2) / 4 - 350; 2157 2158 // retrieve position settings 2159 dvbdev_pos_t scr_position = (dvbdev_pos_t) settings.GetValue(GetDeviceID()); 2160 2161 // check parameters 2162 if (m_scr_userband > 8) 2163 { 2164 LOG(VB_GENERAL, LOG_INFO, QString("SCR: Userband ID=%1 is out of standard range!") 2165 .arg(m_scr_userband)); 2166 } 2167 2168 if (t >= 1024) 2169 { 2170 LOG(VB_GENERAL, LOG_ERR, LOC + "SCR: T out of range!"); 2171 return false; 2172 } 2173 2174 LOG(VB_GENERAL, LOG_INFO, QString("SCR: Tuning to %1kHz, %2, %3 using UB=%4, FREQ=%5MHz, POS=%6%7") 2175 .arg(tuning.frequency) 2176 .arg(high_band ? "HiBand" : "LoBand") 2177 .arg(horizontal ? "H" : "V") 2178 .arg(m_scr_userband) 2179 .arg(m_scr_frequency) 2180 .arg((scr_position) ? "B" : "A") 2181 .arg((m_scr_pin >= 0 && m_scr_pin <= 255) ? 2182 QString(", PIN=%1").arg(m_scr_pin) : QString(""))); 2183 2184 // build command 2185 unsigned char data[3]; 2186 data[0] = t >> 8 | m_scr_userband << 5; 2187 data[1] = t & 0x00FF; 2188 2189 if (high_band) 2190 data[0] |= (1 << 2); 2191 2192 if (horizontal) 2193 data[0] |= (1 << 3); 2194 2195 if (scr_position) 2196 data[0] |= (1 << 4); 2197 2198 // send command 2199 if (m_scr_pin >= 0 && m_scr_pin <= 255) 2200 { 2201 data[2] = m_scr_pin; 2202 return SendCommand(DISEQC_CMD_ODU_MDU, m_repeat, 3, data); 2203 } else { 2204 return SendCommand(DISEQC_CMD_ODU, m_repeat, 2, data); 2205 } 2206 } 2207 2208 bool DiSEqCDevSCR::PowerOff(void) const 2209 { 2210 // check parameters 2211 if (m_scr_userband > 8) 2212 { 2213 LOG(VB_GENERAL, LOG_INFO, QString("SCR: Userband ID=%1 is out of standard range!") 2214 .arg(m_scr_userband)); 2215 } 2216 2217 LOG(VB_CHANNEL, LOG_INFO, LOC + QString("SCR: Power off UB=%1%7") 2218 .arg(m_scr_userband) 2219 .arg((m_scr_pin >= 0 && m_scr_pin <= 255) 2220 ? QString(", PIN=%1").arg(m_scr_pin) 2221 : QString(""))); 2222 2223 // build command 2224 unsigned char data[3]; 2225 data[0] = (uint8_t) (m_scr_userband << 5); 2226 data[1] = 0x00; 2227 2228 // send command 2229 if (m_scr_pin >= 0 && m_scr_pin <= 255) 2230 { 2231 data[2] = m_scr_pin; 2232 return SendCommand(DISEQC_CMD_ODU_MDU, m_repeat, 3, data); 2233 } else { 2234 return SendCommand(DISEQC_CMD_ODU, m_repeat, 2, data); 2235 } 2236 } 2237 2238 bool DiSEqCDevSCR::SendCommand(uint cmd, uint repeats, uint data_len, 2239 unsigned char *data) const 2240 { 2241 (void) repeats; 2242 2243 // power on bus 2244 if (!m_tree.SetVoltage(SEC_VOLTAGE_18)) 2245 return false; 2246 usleep(DISEQC_LONG_WAIT); 2247 2248 // send command 2249 bool ret = m_tree.SendCommand(DISEQC_ADR_SW_ALL, cmd, repeats, data_len, data); 2250 2251 // power off bus 2252 if (!m_tree.SetVoltage(SEC_VOLTAGE_13)) 2253 return false; 2254 2255 return ret; 2256 } 2257 2258 uint DiSEqCDevSCR::GetVoltage(const DiSEqCDevSettings &settings, 2259 const DTVMultiplex &tuning) const 2260 { 2261 return SEC_VOLTAGE_13; 2262 } 2263 2264 uint32_t DiSEqCDevSCR::GetIntermediateFrequency(const uint32_t frequency) const 2265 { 2266 uint t = (frequency / 1000 + m_scr_frequency + 2) / 4 - 350; 2267 return ((t + 350) * 4) * 1000 - frequency; 2268 } 2269 2270 bool DiSEqCDevSCR::Load(void) 2271 { 2272 // populate scr parameters from db 2273 MSqlQuery query(MSqlQuery::InitCon()); 2274 query.prepare( 2275 "SELECT scr_userband, scr_frequency, " 2276 " scr_pin, cmd_repeat " 2277 "FROM diseqc_tree " 2278 "WHERE diseqcid = :DEVID"); 2279 query.bindValue(":DEVID", GetDeviceID()); 2280 2281 if (!query.exec() || !query.isActive()) 2282 { 2283 MythDB::DBError("DiSEqCDevSCR::Load 1", query); 2284 return false; 2285 } 2286 else if (query.next()) 2287 { 2288 m_scr_userband = query.value(0).toUInt(); 2289 m_scr_frequency = query.value(1).toUInt(); 2290 m_scr_pin = query.value(2).toInt(); 2291 m_repeat = query.value(3).toUInt(); 2292 } 2293 2294 // load children from db 2295 if (m_child) 2296 { 2297 delete m_child; 2298 m_child = NULL; 2299 } 2300 2301 query.prepare( 2302 "SELECT diseqcid " 2303 "FROM diseqc_tree " 2304 "WHERE parentid = :DEVID"); 2305 query.bindValue(":DEVID", GetDeviceID()); 2306 2307 if (!query.exec() || !query.isActive()) 2308 { 2309 MythDB::DBError("DiSEqCDevSCR::Load 2", query); 2310 return false; 2311 } 2312 else if (query.next()) 2313 { 2314 uint child_dev_id = query.value(0).toUInt(); 2315 SetChild(0, CreateById(m_tree, child_dev_id)); 2316 } 2317 2318 return true; 2319 } 2320 2321 bool DiSEqCDevSCR::Store(void) const 2322 { 2323 MSqlQuery query(MSqlQuery::InitCon()); 2324 2325 // insert new or update old 2326 if (IsRealDeviceID()) 2327 { 2328 query.prepare( 2329 "UPDATE diseqc_tree " 2330 "SET parentid = :PARENT, " 2331 " ordinal = :ORDINAL, " 2332 " type = 'scr', " 2333 " description = :DESC, " 2334 " scr_userband = :USERBAND, " 2335 " scr_frequency = :FREQUENCY, " 2336 " scr_pin = :PIN, " 2337 " cmd_repeat = :REPEAT " 2338 "WHERE diseqcid = :DEVID"); 2339 query.bindValue(":DEVID", GetDeviceID()); 2340 } 2341 else 2342 { 2343 query.prepare( 2344 "INSERT INTO diseqc_tree" 2345 " ( parentid, ordinal, type, " 2346 " description, scr_userband, scr_frequency, " 2347 " scr_pin, cmd_repeat) " 2348 "VALUES " 2349 " (:PARENT, :ORDINAL, 'scr', " 2350 " :DESC, :USERBAND, :FREQUENCY," 2351 " :PIN, :REPEAT) "); 2352 } 2353 2354 if (m_parent) 2355 query.bindValue(":PARENT", m_parent->GetDeviceID()); 2356 2357 query.bindValue(":ORDINAL", m_ordinal); 2358 query.bindValue(":DESC", GetDescription()); 2359 query.bindValue(":USERBAND", m_scr_userband); 2360 query.bindValue(":FREQUENCY", m_scr_frequency); 2361 query.bindValue(":PIN", m_scr_pin); 2362 query.bindValue(":REPEAT", m_repeat); 2363 2364 // update dev_id 2365 if (!query.exec()) 2366 { 2367 MythDB::DBError("DiSEqCDevSCR::Store", query); 2368 return false; 2369 } 2370 2371 // figure out devid if we did an insert 2372 if (!IsRealDeviceID()) 2373 SetDeviceID(query.lastInsertId().toUInt()); 2374 2375 // chain to child 2376 if (m_child) 2377 return m_child->Store(); 2378 2379 return true; 2380 } 2381 2382 bool DiSEqCDevSCR::SetChild(uint ordinal, DiSEqCDevDevice *device) 2383 { 2384 if (ordinal) 2385 return false; 2386 2387 DiSEqCDevDevice *old_child = m_child; 2388 m_child = NULL; 2389 if (old_child) 2390 delete old_child; 2391 2392 m_child = device; 2393 if (m_child) 2394 { 2395 m_child->SetOrdinal(ordinal); 2396 m_child->SetParent(this); 2397 } 2398 2399 return true; 2400 } 2401 2402 //////////////////////////////////////// 2055 2403 2056 2404 /** \class DiSEqCDevLNB 2057 2405 * \brief LNB Class. -
mythtv/libs/libmythtv/diseqc.h
diff -Naur mythtv-0.26-20130424-g5f45c0b-old/mythtv/libs/libmythtv/diseqc.h mythtv-0.26-20130424-g5f45c0b-new/mythtv/libs/libmythtv/diseqc.h
old new 27 27 class DiSEqCDevDevice; 28 28 class DiSEqCDevRotor; 29 29 class DiSEqCDevLNB; 30 class DiSEqCDevSCR; 30 31 31 32 typedef QMap<uint, double> uint_to_dbl_t; 32 33 typedef QMap<double, uint> dbl_to_uint_t; … … 85 86 86 87 DiSEqCDevRotor *FindRotor(const DiSEqCDevSettings &settings, uint index = 0); 87 88 DiSEqCDevLNB *FindLNB(const DiSEqCDevSettings &settings); 89 DiSEqCDevSCR *FindSCR(const DiSEqCDevSettings &settings); 88 90 DiSEqCDevDevice *FindDevice(uint dev_id); 89 91 90 92 /** \brief Retrieves the root node in the tree. */ … … 94 96 bool SendCommand(uint adr, uint cmd, uint repeats = 0, 95 97 uint data_len = 0, unsigned char *data = NULL); 96 98 97 bool ResetDiseqc(bool hard_reset );99 bool ResetDiseqc(bool hard_reset, bool is_SCR); 98 100 99 101 // frontend fd 100 void Open(int fd_frontend );102 void Open(int fd_frontend, bool is_SCR); 101 103 void Close(void) { m_fd_frontend = -1; } 102 104 int GetFD(void) const { return m_fd_frontend; } 103 105 … … 142 144 virtual bool Store(void) const = 0; 143 145 144 146 // Sets 145 enum dvbdev_t { kTypeSwitch = 0, kTypeRotor = 1, kTypeLNB = 2, }; 147 enum dvbdev_t 148 { 149 kTypeSwitch = 0, 150 kTypeRotor = 1, 151 kTypeSCR = 2, 152 kTypeLNB = 3, 153 }; 146 154 void SetDeviceType(dvbdev_t type) { m_dev_type = type; } 147 155 void SetParent(DiSEqCDevDevice* parent) { m_parent = parent; } 148 156 void SetOrdinal(uint ordinal) { m_ordinal = ordinal; } … … 201 209 const TypeTable *table); 202 210 203 211 private: 204 static const TypeTable dvbdev_lookup[ 4];212 static const TypeTable dvbdev_lookup[5]; 205 213 }; 206 214 207 215 class DiSEqCDevSwitch : public DiSEqCDevDevice … … 359 367 static const TypeTable RotorTypeTable[3]; 360 368 }; 361 369 370 class DiSEqCDevSCR : public DiSEqCDevDevice 371 { 372 public: 373 DiSEqCDevSCR(DiSEqCDevTree &tree, uint devid); 374 ~DiSEqCDevSCR(); 375 376 // Commands 377 virtual void Reset(void); 378 virtual bool Execute(const DiSEqCDevSettings&, const DTVMultiplex&); 379 bool PowerOff(void) const; 380 virtual bool Load(void); 381 virtual bool Store(void) const; 382 383 // Sets 384 enum dvbdev_pos_t 385 { 386 kTypeScrPosA = 0, 387 kTypeScrPosB = 1, 388 }; 389 void SetUserBand(uint userband) { m_scr_userband = userband; } 390 void SetFrequency(uint freq) { m_scr_frequency = freq; } 391 void SetPIN(int pin) { m_scr_pin = pin; } 392 virtual bool SetChild(uint ordinal, DiSEqCDevDevice* device); 393 394 // Gets 395 uint GetUserBand(void) const { return m_scr_userband; } 396 uint GetFrequency(void) const { return m_scr_frequency; } 397 int GetPIN(void) const { return m_scr_pin; } 398 virtual uint GetChildCount(void) const { return 1; } 399 virtual bool IsCommandNeeded(const DiSEqCDevSettings&, 400 const DTVMultiplex&) const { return false; } 401 virtual uint GetVoltage(const DiSEqCDevSettings&, 402 const DTVMultiplex&) const; 403 uint32_t GetIntermediateFrequency(const uint32_t frequency) const; 404 405 // Non-const Gets 406 virtual DiSEqCDevDevice *GetSelectedChild(const DiSEqCDevSettings&) const 407 { return m_child; } 408 virtual DiSEqCDevDevice *GetChild(uint) { return m_child; } 409 410 // statics 411 static QString SCRPositionToString(dvbdev_pos_t pos) 412 { return TableToString((uint)pos, SCRPositionTable); } 413 414 static dvbdev_pos_t SCRPositionFromString(const QString &pos) 415 { return (dvbdev_pos_t) TableFromString(pos, SCRPositionTable); } 416 417 protected: 418 bool SendCommand(uint cmd, uint repeats, uint data_len = 0, 419 unsigned char *data = NULL) const; 420 421 private: 422 uint m_scr_userband; /* 0-7 */ 423 uint m_scr_frequency; 424 int m_scr_pin; /* 0-255, -1=disabled */ 425 426 DiSEqCDevDevice *m_child; 427 428 static const TypeTable SCRPositionTable[3]; 429 }; 430 362 431 class DiSEqCDevLNB : public DiSEqCDevDevice 363 432 { 364 433 public: -
mythtv/libs/libmythtv/diseqcsettings.cpp
diff -Naur mythtv-0.26-20130424-g5f45c0b-old/mythtv/libs/libmythtv/diseqcsettings.cpp mythtv-0.26-20130424-g5f45c0b-new/mythtv/libs/libmythtv/diseqcsettings.cpp
old new 49 49 QString::number((uint) DiSEqCDevDevice::kTypeSwitch)); 50 50 addSelection(DeviceTree::tr("Rotor"), 51 51 QString::number((uint) DiSEqCDevDevice::kTypeRotor)); 52 addSelection(DeviceTree::tr("Unicable"), 53 QString::number((uint) DiSEqCDevDevice::kTypeSCR)); 52 54 addSelection(DeviceTree::tr("LNB"), 53 55 QString::number((uint) DiSEqCDevDevice::kTypeLNB)); 54 56 } … … 109 111 { 110 112 public: 111 113 DeviceRepeatSetting(DiSEqCDevDevice &device) : 112 SpinBoxSetting(this, 0, 5, 1), m_device(device)114 SpinBoxSetting(this, 0, 15, 1), m_device(device) 113 115 { 114 116 setLabel(DeviceTree::tr("Repeat Count")); 115 117 QString help = DeviceTree::tr( 116 "Number of times to repeat DiSEqC commands sent to this device. " 117 "Larger values may help with less reliable devices."); 118 "Number of repeat (command with repeat flag ON) or resend (the same command) DiSEqC commands." 119 "If value is higher than 10, command will be resend N-10 times" 120 "If value is lower than 10, command will be repeated N times" 121 "Repeat useful for unreliable DiSEqC equipment; resend useful when unreliable DiSEq equipment has broken/unsuported repeat flag support."); 118 122 setHelpText(help); 119 123 } 120 124 … … 558 562 config.Save(); 559 563 } 560 564 565 //////////////////////////////////////// SCRUserBandSetting 566 567 class SCRUserBandSetting : public SpinBoxSetting, public Storage 568 { 569 public: 570 SCRUserBandSetting(DiSEqCDevSCR &scr) : 571 SpinBoxSetting(this, 0, 8, 1), m_scr(scr) 572 { 573 setLabel(DeviceTree::tr("Userband")); 574 setHelpText(DeviceTree::tr("Unicable userband ID (0-7) or sometimes (1-8)")); 575 } 576 577 virtual void Load(void) 578 { 579 setValue(m_scr.GetUserBand()); 580 } 581 582 virtual void Save(void) 583 { 584 m_scr.SetUserBand(intValue()); 585 } 586 587 virtual void Save(QString /*destination*/) { } 588 589 private: 590 DiSEqCDevSCR &m_scr; 591 }; 592 593 //////////////////////////////////////// SCRFrequencySetting 594 595 class SCRFrequencySetting : public LineEditSetting, public Storage 596 { 597 public: 598 SCRFrequencySetting(DiSEqCDevSCR &scr) : LineEditSetting(this), m_scr(scr) 599 { 600 setLabel(DeviceTree::tr("Frequency (MHz)")); 601 setHelpText(DeviceTree::tr("Unicable userband frequency (usually 1210, 1420, 1680 and 2040 MHz)")); 602 } 603 604 virtual void Load(void) 605 { 606 setValue(QString::number(m_scr.GetFrequency())); 607 } 608 609 virtual void Save(void) 610 { 611 m_scr.SetFrequency(getValue().toUInt()); 612 } 613 614 virtual void Save(QString /*destination*/) { } 615 616 private: 617 DiSEqCDevSCR &m_scr; 618 }; 619 620 //////////////////////////////////////// SCRPINSetting 621 622 class SCRPINSetting : public LineEditSetting, public Storage 623 { 624 public: 625 SCRPINSetting(DiSEqCDevSCR &scr) : LineEditSetting(this), m_scr(scr) 626 { 627 setLabel(DeviceTree::tr("PIN code")); 628 setHelpText(DeviceTree::tr("Unicable PIN code (-1 disabled, 0 - 255)")); 629 } 630 631 virtual void Load(void) 632 { 633 setValue(QString::number(m_scr.GetPIN())); 634 } 635 636 virtual void Save(void) 637 { 638 m_scr.SetPIN(getValue().toInt()); 639 } 640 641 virtual void Save(QString /*destination*/) { } 642 643 private: 644 DiSEqCDevSCR &m_scr; 645 }; 646 647 //////////////////////////////////////// SCRConfig 648 649 SCRConfig::SCRConfig(DiSEqCDevSCR &scr) : m_scr(scr) 650 { 651 ConfigurationGroup *group = 652 new VerticalConfigurationGroup(false, false); 653 group->setLabel(DeviceTree::tr("Unicable Configuration")); 654 655 group->addChild(new SCRUserBandSetting(scr)); 656 group->addChild(new SCRFrequencySetting(scr)); 657 group->addChild(new SCRPINSetting(scr)); 658 group->addChild(new DeviceRepeatSetting(scr)); 659 660 addChild(group); 661 } 662 561 663 //////////////////////////////////////// LnbPresetSetting 562 664 563 665 class lnb_preset … … 948 1050 } 949 1051 break; 950 1052 1053 case DiSEqCDevDevice::kTypeSCR: 1054 { 1055 DiSEqCDevSCR *scr = dynamic_cast<DiSEqCDevSCR*>(dev); 1056 if (scr) 1057 { 1058 SCRConfig config(*scr); 1059 changed = (config.exec() == MythDialog::Accepted); 1060 } 1061 } 1062 break; 1063 951 1064 case DiSEqCDevDevice::kTypeLNB: 952 1065 { 953 1066 DiSEqCDevLNB *lnb = dynamic_cast<DiSEqCDevLNB*>(dev); … … 977 1090 MythListBox *list = new MythListBox(popup); 978 1091 list->insertItem(tr("Switch")); 979 1092 list->insertItem(tr("Rotor")); 1093 list->insertItem(tr("Unicable")); 980 1094 list->insertItem(tr("LNB")); 981 1095 list->setCurrentRow(0, QItemSelectionModel::Select); 982 1096 … … 1263 1377 DiSEqCDevSettings &m_settings; 1264 1378 }; 1265 1379 1380 //////////////////////////////////////// SCRPositionSetting 1381 1382 class SCRPositionSetting : public ComboBoxSetting, public Storage 1383 { 1384 public: 1385 SCRPositionSetting(DiSEqCDevDevice &node, DiSEqCDevSettings &settings) 1386 : ComboBoxSetting(this), m_node(node), m_settings(settings) 1387 { 1388 setLabel("Position"); 1389 setHelpText(DeviceTree::tr("Unicable satellite position (A/B)")); 1390 addSelection(DiSEqCDevSCR::SCRPositionToString(DiSEqCDevSCR::kTypeScrPosA), 1391 QString::number((uint)DiSEqCDevSCR::kTypeScrPosA), true); 1392 addSelection(DiSEqCDevSCR::SCRPositionToString(DiSEqCDevSCR::kTypeScrPosB), 1393 QString::number((uint)DiSEqCDevSCR::kTypeScrPosB), false); 1394 } 1395 1396 virtual void Load(void) 1397 { 1398 double value = m_settings.GetValue(m_node.GetDeviceID()); 1399 setValue(getValueIndex(QString::number((uint)value))); 1400 } 1401 1402 virtual void Save(void) 1403 { 1404 m_settings.SetValue(m_node.GetDeviceID(), getValue().toDouble()); 1405 } 1406 1407 virtual void Save(QString /*destination*/) { } 1408 1409 private: 1410 DiSEqCDevDevice &m_node; 1411 DiSEqCDevSettings &m_settings; 1412 }; 1413 1266 1414 //////////////////////////////////////// DTVDeviceConfigGroup 1267 1415 1268 1416 DTVDeviceConfigGroup::DTVDeviceConfigGroup( … … 1305 1453 setting = new USALSRotorSetting(*node, m_settings); 1306 1454 break; 1307 1455 } 1456 case DiSEqCDevDevice::kTypeSCR: 1457 { 1458 setting = new SCRPositionSetting(*node, m_settings); 1459 break; 1460 } 1308 1461 default: 1309 1462 break; 1310 1463 } … … 1379 1532 DISEQC_POSITIONER_X_SWITCH_2 = 9, 1380 1533 DISEQC_SW21 = 10, 1381 1534 DISEQC_SW64 = 11, 1535 DISEQC_SCR = 12, 1382 1536 }; 1383 1537 1384 1538 // import old diseqc configuration into tree … … 1548 1702 break; 1549 1703 } 1550 1704 1705 case DISEQC_SCR: 1706 { 1707 // SCR + LNB 1708 root = DiSEqCDevDevice::CreateByType( 1709 tree, DiSEqCDevDevice::kTypeSCR); 1710 DiSEqCDevSCR *scr = dynamic_cast<DiSEqCDevSCR*>(root); 1711 if (scr) 1712 { 1713 add_lnbs = 1; 1714 } 1715 break; 1716 } 1717 1551 1718 default: 1552 1719 { 1553 1720 LOG(VB_GENERAL, LOG_ERR, "Unknown DiSEqC device type " + … … 1614 1781 1615 1782 case DISEQC_POSITIONER_1_2: 1616 1783 case DISEQC_POSITIONER_X: 1784 case DISEQC_SCR: 1617 1785 lnb = dynamic_cast<DiSEqCDevLNB*>(root->GetChild(0)); 1618 1786 set.SetValue(root->GetDeviceID(), pos); 1619 1787 break; -
mythtv/libs/libmythtv/diseqcsettings.h
diff -Naur mythtv-0.26-20130424-g5f45c0b-old/mythtv/libs/libmythtv/diseqcsettings.h mythtv-0.26-20130424-g5f45c0b-new/mythtv/libs/libmythtv/diseqcsettings.h
old new 73 73 TransButtonSetting *m_pos; 74 74 }; 75 75 76 class SCRConfig : public QObject, public ConfigurationWizard 77 { 78 Q_OBJECT 79 80 public: 81 SCRConfig(DiSEqCDevSCR &scr); 82 83 private: 84 DiSEqCDevSCR &m_scr; 85 }; 86 76 87 class LNBTypeSetting; 77 88 class LNBLOFSwitchSetting; 78 89 class LNBLOFLowSetting; -
mythtv/libs/libmythtv/dvbchannel.cpp
diff -Naur mythtv-0.26-20130424-g5f45c0b-old/mythtv/libs/libmythtv/dvbchannel.cpp mythtv-0.26-20130424-g5f45c0b-new/mythtv/libs/libmythtv/dvbchannel.cpp
old new 267 267 // Turn on the power to the LNB 268 268 if (tunerType.IsDiSEqCSupported()) 269 269 { 270 270 271 diseqc_tree = diseqc_dev.FindTree(GetCardID()); 271 272 if (diseqc_tree) 272 diseqc_tree->Open(fd_frontend); 273 { 274 bool is_SCR = false; 275 276 DiSEqCDevSCR *scr = diseqc_tree->FindSCR(diseqc_settings); 277 if (scr) 278 { 279 is_SCR = true; 280 LOG(VB_CHANNEL, LOG_INFO, LOC + "Requested DVB channel is on SCR system"); 281 } 282 else 283 LOG(VB_CHANNEL, LOG_INFO, LOC + "Requested DVB channel is on non-SCR system"); 284 285 diseqc_tree->Open(fd_frontend, is_SCR); 286 } 273 287 } 274 288 275 289 dvbcam->Start(); … … 678 692 // Remove any events in queue before tuning. 679 693 drain_dvb_events(fd_frontend); 680 694 681 // send DVB-S setup 682 if (diseqc_tree) 683 { 684 // configure for new input 685 if (!same_input) 686 diseqc_settings.Load(inputid); 687 688 // execute diseqc commands 689 if (!diseqc_tree->Execute(diseqc_settings, tuning)) 690 { 691 LOG(VB_GENERAL, LOG_ERR, LOC + 692 "Tune(): Failed to setup DiSEqC devices"); 693 return false; 694 } 695 696 // retrieve actual intermediate frequency 697 DiSEqCDevLNB *lnb = diseqc_tree->FindLNB(diseqc_settings); 698 if (!lnb) 699 { 700 LOG(VB_GENERAL, LOG_ERR, LOC + 701 "Tune(): No LNB for this configuration"); 702 return false; 703 } 704 705 if (lnb->GetDeviceID() != last_lnb_dev_id) 706 { 707 last_lnb_dev_id = lnb->GetDeviceID(); 708 // make sure we tune to frequency, if the lnb has changed 709 reset = first_tune = true; 710 } 711 712 intermediate_freq = lnb->GetIntermediateFrequency( 713 diseqc_settings, tuning); 714 715 // if card can auto-FEC, use it -- sometimes NITs are inaccurate 716 if (capabilities & FE_CAN_FEC_AUTO) 717 can_fec_auto = true; 718 719 // Check DVB-S intermediate frequency here since it requires a fully 720 // initialized diseqc tree 721 CheckFrequency(intermediate_freq); 722 } 723 724 LOG(VB_CHANNEL, LOG_INFO, LOC + "Old Params: " + prev_tuning.toString() + 725 "\n\t\t\t" + LOC + "New Params: " + tuning.toString()); 695 LOG(VB_CHANNEL, LOG_INFO, LOC + "\nOld Params: " + prev_tuning.toString() + 696 "\nNew Params: " + tuning.toString()); 726 697 727 698 // DVB-S is in kHz, other DVB is in Hz 728 699 bool is_dvbs = ((DTVTunerType::kTunerTypeDVBS1 == tunerType) || … … 736 707 .arg(intermediate_freq ? intermediate_freq : tuning.frequency) 737 708 .arg(suffix)); 738 709 710 // send DVB-S setup 711 if (diseqc_tree) 712 { 713 // configure for new input 714 if (!same_input) 715 diseqc_settings.Load(inputid); 716 717 // execute diseqc commands 718 if (!diseqc_tree->Execute(diseqc_settings, tuning)) 719 { 720 LOG(VB_GENERAL, LOG_ERR, LOC + 721 "Tune(): Failed to setup DiSEqC devices"); 722 return false; 723 } 724 725 // retrieve actual intermediate frequency 726 DiSEqCDevLNB *lnb = diseqc_tree->FindLNB(diseqc_settings); 727 if (!lnb) 728 { 729 LOG(VB_GENERAL, LOG_ERR, LOC + 730 "Tune(): No LNB for this configuration"); 731 return false; 732 } 733 734 if (lnb->GetDeviceID() != last_lnb_dev_id) 735 { 736 last_lnb_dev_id = lnb->GetDeviceID(); 737 // make sure we tune to frequency, if the lnb has changed 738 reset = first_tune = true; 739 } 740 741 intermediate_freq = lnb->GetIntermediateFrequency( 742 diseqc_settings, tuning); 743 744 // retrieve scr intermediate frequency 745 DiSEqCDevSCR *scr = diseqc_tree->FindSCR(diseqc_settings); 746 if (lnb && scr) 747 { 748 intermediate_freq = scr->GetIntermediateFrequency(intermediate_freq); 749 } 750 751 // if card can auto-FEC, use it -- sometimes NITs are inaccurate 752 if (capabilities & FE_CAN_FEC_AUTO) 753 can_fec_auto = true; 754 755 // Check DVB-S intermediate frequency here since it requires a fully 756 // initialized diseqc tree 757 CheckFrequency(intermediate_freq); 758 } 759 739 760 #if DVB_API_VERSION >=5 740 761 if (DTVTunerType::kTunerTypeDVBS2 == tunerType) 741 762 {