Ticket #973: 5-mythtv_multilnb_positioner_rev2.diff
File 5-mythtv_multilnb_positioner_rev2.diff, 31.3 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/dvbdiseqc.cpp
diff -Naur mythtv/libs/libmythtv/dvbdiseqc.cpp mythtv-diseqc/libs/libmythtv/dvbdiseqc.cpp
old new 13 13 * - DiSEqC 1.0 - 1.1. 14 14 * Kenneth Aafloy (ke-aa at frisurf.no) 15 15 * - Initial framework. 16 * Zdzislaw Gorlicki (zdzisekg at yahoo.com 17 * - DiSEqC 1.2/1.3 + switch 16 18 * 17 19 * This program is free software; you can redistribute it and/or modify 18 20 * it under the terms of the GNU General Public License as published by … … 84 86 break; 85 87 case 6: // 1.2 Positioner (HH Motor) 86 88 if (!PositionerGoto(tuning,reset,havetuned)) 87 89 return false; 88 90 break; 89 91 case 7: // 1.3 Positioner (HH Motor with USALS) 90 92 if (!PositionerGotoAngular(tuning,reset,havetuned)) 91 93 return false; 92 94 break; 93 95 case 8: // v1.1 10 Way 94 96 if (!Diseqc1xSwitch(tuning, reset, havetuned, 10)) 95 97 return false; 96 98 break; 97 99 case 10: // 1.2 Positioner (HH Motor with a switch behind it) 100 if (!PositionerGoto(tuning,reset,havetuned)) 101 return false; 102 break; 103 case 11: // 1.3 Positioner (HH Motor with USALS and with a switch behind it) 104 if (!PositionerGotoAngular(tuning, reset, havetuned)) 105 return false; 106 break; 98 107 default: 99 108 VERBOSE(VB_IMPORTANT, LOC_ERR + "Unsupported DiSEqC type(" 100 109 <<tuning.diseqc_type<<")"); 101 110 } 102 111 103 112 return true; 104 113 } 105 114 … … 156 165 VERBOSE(VB_IMPORTANT, LOC_ERR + 157 166 "Tone Switches only support two ports."); 158 167 168 // I think SEC_MINI_A is 0 in DB so we should compare against that. right? 159 169 if (ioctl(fd_frontend, FE_DISEQC_SEND_BURST, 160 (tuning.diseqc_port == 1? SEC_MINI_A : SEC_MINI_B )) < 0)170 (tuning.diseqc_port == 0 ? SEC_MINI_A : SEC_MINI_B )) < 0) 161 171 { 162 172 VERBOSE(VB_IMPORTANT, LOC_ERR + 163 173 "Setting Tone Switch failed." + ENO); … … 175 185 /***************************************************************************** 176 186 Diseqc 1.x Compatible Methods 177 187 ****************************************************************************/ 188 bool DVBDiSEqC::DiseqcReset() 189 { 190 struct dvb_diseqc_master_cmd reset_cmd = 191 {{CMD_FIRST, MASTER_TO_LSS, RESET, 0x00, 0x00}, 3}; 192 193 struct dvb_diseqc_master_cmd init_cmd = 194 {{CMD_FIRST, MASTER_TO_LSS, POWERON, 0x00, 0x00}, 3}; 178 195 179 bool DVBDiSEqC::SendDiSEqCMessage(DVBTuning& tuning, dvb_diseqc_master_cmd &cmd) 196 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &init_cmd) <0) 197 { 198 VERBOSE(VB_IMPORTANT, LOC_ERR + 199 "Setup: Sending init command failed." + ENO); 200 return false; 201 } 202 usleep(DISEQC_LONG_WAIT); 203 204 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &reset_cmd) <0) 205 { 206 VERBOSE(VB_IMPORTANT, LOC_ERR + 207 "Setup: Sending reset command failed." + ENO); 208 return false; 209 } 210 usleep(DISEQC_LONG_WAIT); 211 212 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &init_cmd) <0) 213 { 214 VERBOSE(VB_IMPORTANT, LOC_ERR + 215 "Setup: Sending init command failed." + ENO); 216 return false; 217 } 218 usleep(DISEQC_LONG_WAIT); 219 220 return true; 221 } 222 223 224 bool DVBDiSEqC::SendDiSEqCPrepareBus(DVBTuning& tuning, bool reset) 180 225 { 181 // Turn off tone burst 182 if (ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF) == -1) 226 // Reset "visible" DiSEqC switches or LNBs 227 if (reset) 228 { 229 if (!DiseqcReset()) 230 { 231 VERBOSE(VB_IMPORTANT, LOC_ERR + "DiseqcReset() failed"); 232 return false; 233 } 234 } 235 236 // Turn off Continuous tone 237 if (ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF) == -1) 183 238 { 184 239 VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_SET_TONE failed" + ENO); 185 240 return false; 186 241 } 242 else 243 { 244 VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Continuous Tone set to: OFF")); 245 } 187 246 188 /* 189 Old version of the code set the voltage to 13V everytime. 190 After looking at the EutelSat specs I saw no reason that 191 this was done. I have tested this with my DiSEqC switch 192 and all is fine. 193 */ 194 195 if (ioctl(fd_frontend, FE_SET_VOLTAGE, tuning.voltage) == -1) 247 // Set Voltage 248 if (ioctl(fd_frontend, FE_SET_VOLTAGE, tuning.voltage) == -1) 196 249 { 197 250 VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_SET_VOLTAGE failed" + ENO); 198 251 return false; 199 } 252 } 253 else 254 { 255 VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Voltage set to: %1") 256 .arg(tuning.voltage==SEC_VOLTAGE_13?"13V":"18V")); 257 } 200 258 201 usleep(DISEQC_SHORT_WAIT); 259 return true; 260 } 202 261 203 VERBOSE(VB_CHANNEL, LOC + QString("Sending 1.0 Command: %1 %2 %3 %4") 204 .arg(cmd.msg[0], 2, 16)205 .arg(cmd.msg[1], 2, 16) 206 .arg(cmd.msg[2], 2, 16)207 .arg(cmd.msg[3], 2, 16));262 263 bool DVBDiSEqC::SendDiSEqCMessage(DVBTuning& tuning, dvb_diseqc_master_cmd &cmd) 264 { 265 // Send the DiSEqC command 266 usleep(DISEQC_SHORT_WAIT); 208 267 209 268 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1) 210 269 { … … 212 271 "FE_DISEQC_SEND_MASTER_CMD failed" + ENO); 213 272 return false; 214 273 } 274 else 275 { 276 if ((tuning.diseqc_type == 7) || (tuning.diseqc_type == 11)) 277 { 278 VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Sent 1.3 Command: %1 %2 %3 %4 %5") 279 .arg(cmd.msg[FRAME], 2, 16) 280 .arg(cmd.msg[ADDRESS], 2, 16) 281 .arg(cmd.msg[COMMAND], 2, 16) 282 .arg(cmd.msg[DATA_1], 2, 16) 283 .arg(cmd.msg[DATA_2], 2, 16)); 284 } 285 else 286 { 287 VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Sent 1.0 Command: %1 %2 %3 %4") 288 .arg(cmd.msg[FRAME], 2, 16) 289 .arg(cmd.msg[ADDRESS], 2, 16) 290 .arg(cmd.msg[COMMAND], 2, 16) 291 .arg(cmd.msg[DATA_1], 2, 16)); 292 } 293 } 215 294 216 usleep(DISEQC_SHORT_WAIT); 217 218 // Check to see if its a 1.1 or 1.2 device. If so repeat the message repeats times. 295 // Check to see if its a 1.1, 1.2 or 1.3 device. If so repeat the message repeats times. 219 296 if ((tuning.diseqc_type == 3) || (tuning.diseqc_type == 5) || 220 (tuning.diseqc_type == 6) || (tuning.diseqc_type == 7)) 297 (tuning.diseqc_type == 6) || (tuning.diseqc_type == 7) || 298 (tuning.diseqc_type == 10) || (tuning.diseqc_type == 11)) 221 299 { 300 int repeats; 301 if((tuning.diseqc_type == 10) || (tuning.diseqc_type == 11)) 302 { 303 repeats = repeat + 1; 304 } 305 else 306 { 307 repeats = repeat; 308 } 222 309 223 int repeats = repeat;224 310 while (repeats--) 225 311 { 226 227 if (tuning.diseqc_type == 7) 228 { 229 VERBOSE(VB_CHANNEL, LOC + 230 QString("Sending 1.3 Repeat Command: %1 %2 %3 %4 %5") 231 .arg(cmd.msg[0],2,16) 232 .arg(cmd.msg[1],2,16) 233 .arg(cmd.msg[2],2,16) 234 .arg(cmd.msg[3],2,16) 235 .arg(cmd.msg[4],2,16)); 236 } 237 else 238 { 239 VERBOSE(VB_CHANNEL, LOC + 240 QString("Sending 1.1/1.2 Repeat Command: %1 %2 %3 %4") 241 .arg(cmd.msg[0],2,16) 242 .arg(cmd.msg[1],2,16) 243 .arg(cmd.msg[2],2,16) 244 .arg(cmd.msg[3],2,16)); 245 } 246 247 cmd.msg[0] = CMD_REPEAT; 312 usleep(DISEQC_SHORT_WAIT); 313 cmd.msg[FRAME] = CMD_REPEAT; 248 314 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1) 249 315 { 250 316 VERBOSE(VB_IMPORTANT, LOC_ERR + 251 317 "FE_DISEQC_SEND_MASTER_CMD failed" + ENO); 252 318 return false; 253 319 } 254 usleep(DISEQC_SHORT_WAIT); 255 256 cmd.msg[0] = CMD_FIRST; 257 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1) 320 else 258 321 { 259 VERBOSE(VB_IMPORTANT, LOC_ERR + 260 "FE_DISEQC_SEND_MASTER_CMD failed" + ENO); 261 return false; 322 if ((tuning.diseqc_type == 7) || (tuning.diseqc_type == 11)) 323 { 324 VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Sent 1.3 Repeat Command: %1 %2 %3 %4 %5") 325 .arg(cmd.msg[FRAME], 2, 16) 326 .arg(cmd.msg[ADDRESS], 2, 16) 327 .arg(cmd.msg[COMMAND], 2, 16) 328 .arg(cmd.msg[DATA_1], 2, 16) 329 .arg(cmd.msg[DATA_2], 2, 16)); 330 } 331 else 332 { 333 VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Sent 1.0 Repeat Command: %1 %2 %3 %4") 334 .arg(cmd.msg[FRAME], 2, 16) 335 .arg(cmd.msg[ADDRESS], 2, 16) 336 .arg(cmd.msg[COMMAND], 2, 16) 337 .arg(cmd.msg[DATA_1], 2, 16)); 338 } 262 339 } 263 usleep(DISEQC_SHORT_WAIT);264 340 } 265 341 } 266 342 267 if (ioctl(fd_frontend, FE_DISEQC_SEND_BURST, SEC_MINI_A ) == -1)268 {269 VERBOSE(VB_IMPORTANT, LOC_ERR +270 "FE_DISEQC_SEND_BURST failed" + ENO);271 return false;272 }273 274 343 usleep(DISEQC_SHORT_WAIT); 275 344 276 if (ioctl(fd_frontend, FE_SET_TONE, tuning.tone) == -1)277 {278 VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_SET_TONE failed" + ENO);279 return false;280 }281 282 345 return true; 283 346 } 284 347 285 348 286 bool DVBDiSEqC::SendDiSEqC Message(dvb_diseqc_master_cmd &cmd)349 bool DVBDiSEqC::SendDiSEqCSetupBus(DVBTuning& tuning) 287 350 { 288 // Turn off tone burst 289 if (ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF) == -1) 351 //Determin the Tone Burst for switches with more then 2 ports and send it 352 //This one I had hard time figuring out from the specs at eutelsat 353 //I guess the tone burst can be interpreted differently for different setups 354 //but in our case (with pure diseqc) it may only affect the LNB 355 if (ioctl(fd_frontend, FE_DISEQC_SEND_BURST, 356 ((tuning.diseqc_port % 2) == 0 ? SEC_MINI_A : SEC_MINI_B )) < 0) 290 357 { 291 VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_SET_TONE failed" + ENO); 358 VERBOSE(VB_IMPORTANT, LOC_ERR + 359 "FE_DISEQC_SEND_BURST failed" + ENO); 292 360 return false; 293 361 } 294 295 usleep(DISEQC_SHORT_WAIT); 296 297 VERBOSE(VB_CHANNEL, LOC + QString("Sending 1.0 Command: %1 %2 %3 %4") 298 .arg(cmd.msg[0], 2, 16) 299 .arg(cmd.msg[1], 2, 16) 300 .arg(cmd.msg[2], 2, 16) 301 .arg(cmd.msg[3], 2, 16)); 302 303 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1) 362 else 304 363 { 305 VERBOSE(VB_IMPORTANT, LOC_ERR + 306 "FE_DISEQC_SEND_MASTER_CMD failed" + ENO); 307 return false; 364 VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Tone Burst set to: %1") 365 .arg((tuning.diseqc_port % 2) == 0 ? "A" : "B")); 308 366 } 309 367 310 368 usleep(DISEQC_SHORT_WAIT); 311 312 int repeats = repeat;313 while (repeats--)314 {315 VERBOSE(VB_CHANNEL, LOC +316 QString("Sending 1.1/1.2/1.3 Repeat Command: %1 %2 %3 %4")317 .arg(cmd.msg[0], 2, 16)318 .arg(cmd.msg[1], 2, 16)319 .arg(cmd.msg[2], 2, 16)320 .arg(cmd.msg[3], 2, 16));321 369 322 cmd.msg[0] = CMD_REPEAT; 323 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1) 324 { 325 VERBOSE(VB_IMPORTANT, LOC_ERR + 326 "FE_DISEQC_SEND_MASTER_CMD failed" + ENO); 327 return false; 328 } 329 usleep(DISEQC_SHORT_WAIT); 330 331 cmd.msg[0] = CMD_FIRST; 332 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd) == -1) 333 { 334 VERBOSE(VB_IMPORTANT, LOC_ERR + 335 "FE_DISEQC_SEND_MASTER_CMD failed" + ENO); 336 return false; 337 } 338 usleep(DISEQC_SHORT_WAIT); 339 } 340 341 if (ioctl(fd_frontend, FE_DISEQC_SEND_BURST, SEC_MINI_A ) == -1) 370 //finally, set the continuous tone 371 if (ioctl(fd_frontend, FE_SET_TONE, tuning.tone) == -1) 342 372 { 343 VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_ DISEQC_SEND_BURSTfailed" + ENO);373 VERBOSE(VB_IMPORTANT, LOC_ERR + "FE_SET_TONE failed" + ENO); 344 374 return false; 345 375 } 376 else 377 { 378 VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Continuous Tone set to: %1") 379 .arg(tuning.tone == 0 ? "OFF" : "ON")); 380 } 346 381 347 382 return true; 348 383 } 349 384 385 350 386 bool DVBDiSEqC::Diseqc1xSwitch(DVBTuning& tuning, bool reset, 351 387 bool& havetuned, uint ports) 352 388 { 353 if (reset)354 {355 if (!DiseqcReset())356 {357 VERBOSE(VB_IMPORTANT, LOC_ERR + "DiseqcReset() failed");358 return false;359 }360 }361 362 VERBOSE(VB_CHANNEL, LOC +363 QString("1.1 Switch (%1 ports) - Port %2 - %3 %4")364 .arg(ports)365 .arg(tuning.diseqc_port)366 .arg(tuning.tone==SEC_TONE_ON?"Tone ON":"Tone OFF")367 .arg(tuning.voltage==SEC_VOLTAGE_13?"13V":"18V"));368 369 389 if ((prev_tuning.diseqc_port != tuning.diseqc_port || 370 390 prev_tuning.tone != tuning.tone || 371 391 prev_tuning.voltage != tuning.voltage ) || reset) … … 399 418 "Unsupported number of ports for DiSEqC 1.1 Switch"); 400 419 } 401 420 421 if (!SendDiSEqCPrepareBus(tuning, reset)) 422 { 423 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment I"); 424 return false; 425 } 426 402 427 if (!SendDiSEqCMessage(tuning,cmd)) 403 428 { 404 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed."); 429 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed. -> Segment II"); 430 return false; 431 } 432 433 if (!SendDiSEqCSetupBus(tuning)) 434 { 435 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment III"); 405 436 return false; 406 437 } 407 438 … … 420 451 return true; 421 452 } 422 453 423 bool DVBDiSEqC::DiseqcReset()424 {425 struct dvb_diseqc_master_cmd reset_cmd =426 {{CMD_FIRST, MASTER_TO_LSS, RESET, 0x00, 0x00}, 3};427 428 struct dvb_diseqc_master_cmd init_cmd =429 {{CMD_FIRST, MASTER_TO_LSS, POWERON, 0x00, 0x00}, 3};430 431 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &init_cmd) <0)432 {433 VERBOSE(VB_IMPORTANT, LOC_ERR +434 "Setup: Sending init command failed." + ENO);435 return false;436 }437 usleep(DISEQC_LONG_WAIT);438 439 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &reset_cmd) <0)440 {441 VERBOSE(VB_IMPORTANT, LOC_ERR +442 "Setup: Sending reset command failed." + ENO);443 return false;444 }445 usleep(DISEQC_LONG_WAIT);446 447 if (ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &init_cmd) <0)448 {449 VERBOSE(VB_IMPORTANT, LOC_ERR +450 "Setup: Sending init command failed." + ENO);451 return false;452 }453 usleep(DISEQC_LONG_WAIT);454 455 return true;456 }457 454 458 455 /***************************************************************************** 459 456 Positioner Control 460 457 *****************************************************************************/ 461 458 /* 459 // Currently not used so not needed, also will need to be modified 460 // to be used with current way of sending DiSEqC messages 462 461 bool DVBDiSEqC::PositionerDriveEast(int timestep) 463 462 { 464 463 if (!DiseqcReset()) … … 475 474 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed."); 476 475 return false; 477 476 } 478 477 479 478 return true; 480 479 } 481 480 … … 499 498 return true; 500 499 } 501 500 502 bool DVBDiSEqC::PositionerGoto(DVBTuning& tuning, bool reset, bool& havetuned)503 {504 // A reset seems to be required for my positioner to work consistently505 VERBOSE(VB_CHANNEL, LOC + QString("1.2 Motor - Goto Stored Position %1")506 .arg(tuning.diseqc_port));507 508 if ((prev_tuning.diseqc_port != tuning.diseqc_port ||509 prev_tuning.tone != tuning.tone ||510 prev_tuning.voltage != tuning.voltage) || reset)511 {512 if (!DiseqcReset())513 {514 VERBOSE(VB_IMPORTANT, LOC_ERR + "DiseqcReset() failed");515 return false;516 }517 518 dvb_diseqc_master_cmd cmd =519 {{CMD_FIRST, MASTER_TO_POSITIONER, GOTO, tuning.diseqc_port,520 0x00, 0x00}, 4};521 522 if (!SendDiSEqCMessage(tuning,cmd))523 {524 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed.");525 return false;526 }527 528 prev_tuning.diseqc_port = tuning.diseqc_port;529 prev_tuning.tone = tuning.tone;530 prev_tuning.voltage = tuning.voltage;531 }532 533 havetuned |=534 (prev_tuning.diseqc_port == tuning.diseqc_port) &&535 (prev_tuning.voltage == tuning.voltage) &&536 (prev_tuning.tone == tuning.tone);537 538 return true;539 }540 541 501 bool DVBDiSEqC::PositionerStore(DVBTuning& tuning) 542 502 { 543 503 if (!DiseqcReset()) … … 649 609 650 610 return true; 651 611 } 612 */ 652 613 653 614 /***************************************************************************** 654 Diseqc v1.3 (Goto X) 615 Diseqc Psitioner v1.2 616 ****************************************************************************/ 617 bool DVBDiSEqC::PositionerGoto(DVBTuning& tuning, bool reset, bool& havetuned) 618 { 619 if ((prev_tuning.diseqc_port != tuning.diseqc_port || 620 prev_tuning.tone != tuning.tone || 621 prev_tuning.diseqc_pos != tuning.diseqc_pos || 622 prev_tuning.voltage != tuning.voltage ) || reset) 623 { 624 dvb_diseqc_master_cmd cmd_1 = 625 {{CMD_FIRST, MASTER_TO_POSITIONER, GOTO, tuning.diseqc_pos, 626 0x00, 0x00}, 4}; 627 628 VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Goto Stored Position %1") 629 .arg(tuning.diseqc_pos)); 630 631 if (!SendDiSEqCPrepareBus(tuning, reset)) 632 { 633 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment I"); 634 return false; 635 } 636 637 if (!SendDiSEqCMessage(tuning,cmd_1)) 638 { 639 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed. -> Segment II"); 640 return false; 641 } 642 643 if (tuning.diseqc_type == 10) 644 { 645 dvb_diseqc_master_cmd cmd_2 = 646 {{CMD_FIRST, MASTER_TO_LSS, WRITE_N0, 0xf0, 0x00, 0x00}, 4}; 647 648 cmd_2.msg[DATA_1] = 649 0xF0 | 650 (((tuning.diseqc_port) * 4) & 0x0F) | 651 ((tuning.voltage == SEC_VOLTAGE_18) ? 2 : 0) | 652 ((tuning.tone == SEC_TONE_ON) ? 1 : 0); 653 654 if (!SendDiSEqCMessage(tuning,cmd_2)) 655 { 656 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed. -> Segment II"); 657 return false; 658 } 659 } 660 661 if (!SendDiSEqCSetupBus(tuning)) 662 { 663 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment III"); 664 return false; 665 } 666 667 prev_tuning.diseqc_port = tuning.diseqc_port; 668 prev_tuning.diseqc_pos = tuning.diseqc_pos; 669 prev_tuning.tone = tuning.tone; 670 prev_tuning.voltage = tuning.voltage; 671 } 672 673 havetuned |= 674 (prev_tuning.diseqc_port == tuning.diseqc_port) && 675 (prev_tuning.diseqc_pos == tuning.diseqc_pos) && 676 (prev_tuning.voltage == tuning.voltage) && 677 (prev_tuning.tone == tuning.tone); 678 679 return true; 680 } 681 682 683 /***************************************************************************** 684 Diseqc Positioner v1.3 (Goto X) 655 685 ****************************************************************************/ 656 686 657 687 bool DVBDiSEqC::PositionerGotoAngular(DVBTuning& tuning, bool reset, 658 688 bool& havetuned) 659 689 { 690 /* 660 691 // TODO: Send information here to FE saying motor is moving and 661 692 // to expect a longer than average tuning delay 662 693 if (prev_tuning.diseqc_pos != tuning.diseqc_pos) 663 694 VERBOSE(VB_CHANNEL, LOC + "DiSEqC Motor Moving"); 695 */ 664 696 665 697 int CMD1=0x00 , CMD2=0x00; // Bytes sent to motor 666 698 double USALS=0.0; … … 679 711 double el = atan( (cos(x) - 0.1513 ) /sin(x) ); 680 712 double Azimuth = atan((-cos(el)*sin(az))/(sin(el)*cos(P)-cos(el)*sin(P)*cos(az)))* TO_DEC; 681 713 682 // printf("Offset = %f\n",Azimuth);683 684 714 if (Azimuth > 0.0) 685 715 CMD1=0xE0; // East 686 716 else 687 717 CMD1=0xD0; // West 688 718 689 719 USALS = fabs(Azimuth); 690 720 691 721 while (USALS > 16) 692 722 { 693 723 CMD1++; 694 724 USALS -=16; 695 725 } 696 726 697 727 while (USALS >= 1.0) 698 728 { 699 729 CMD2+=0x10; 700 730 USALS--; 701 731 } 702 732 703 733 CMD2 += DecimalLookup[(int)round(USALS*10)]; 704 705 if (!DiseqcReset())706 {707 VERBOSE(VB_IMPORTANT, LOC_ERR + "DiseqcReset() failed");708 return false;709 }710 734 711 735 // required db changes - get lat and lon for ground station location in db 712 736 // and added to tuning 713 737 // sat_pos be passed into tuning, and be a float not an int./ 714 738 715 VERBOSE(VB_CHANNEL, LOC + QString("1.3 Motor - Goto Angular Position %1")716 .arg(tuning.diseqc_pos));717 718 739 if ((prev_tuning.diseqc_port != tuning.diseqc_port || 719 740 prev_tuning.tone != tuning.tone || 720 741 prev_tuning.diseqc_pos != tuning.diseqc_pos || 721 742 prev_tuning.voltage != tuning.voltage ) || reset) 722 743 { 723 724 dvb_diseqc_master_cmd cmd = 744 dvb_diseqc_master_cmd cmd_1 = 725 745 {{CMD_FIRST, MASTER_TO_POSITIONER, GOTO_ANGULAR, CMD1 , CMD2 , 726 746 0x00}, 5}; 727 747 728 if (!SendDiSEqCMessage(tuning,cmd)) 748 VERBOSE(VB_CHANNEL, LOC + QString("DiSEqC -> Goto Angular Position %1") 749 .arg(tuning.diseqc_pos)); 750 751 if (!SendDiSEqCPrepareBus(tuning, reset)) 729 752 { 730 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed."); 753 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment I"); 754 return false; 755 } 756 757 if (!SendDiSEqCMessage(tuning,cmd_1)) 758 { 759 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed. -> Segment II"); 760 return false; 761 } 762 763 if (tuning.diseqc_type == 11) 764 { 765 dvb_diseqc_master_cmd cmd_2 = 766 {{CMD_FIRST, MASTER_TO_LSS, WRITE_N0, 0xf0, 0x00, 0x00}, 4}; 767 768 cmd_2.msg[DATA_1] = 769 0xF0 | 770 (((tuning.diseqc_port) * 4) & 0x0F) | 771 ((tuning.voltage == SEC_VOLTAGE_18) ? 2 : 0) | 772 ((tuning.tone == SEC_TONE_ON) ? 1 : 0); 773 774 if (!SendDiSEqCMessage(tuning,cmd_2)) 775 { 776 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed. -> Segment II"); 777 return false; 778 } 779 } 780 781 if (!SendDiSEqCSetupBus(tuning)) 782 { 783 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting DiSEqC failed -> Segment III"); 731 784 return false; 732 785 } 733 786 … … 744 797 (prev_tuning.tone == tuning.tone); 745 798 746 799 return true; 747 } 800 } 801 No newline at end of file -
libs/libmythtv/dvbdiseqc.h
diff -Naur mythtv/libs/libmythtv/dvbdiseqc.h mythtv-diseqc/libs/libmythtv/dvbdiseqc.h
old new 31 31 DVBTuning prev_tuning; 32 32 int repeat; 33 33 34 35 bool SendDiSEqCMessage(DVBTuning& tuning, dvb_diseqc_master_cmd &cmd);36 bool SendDiSEqCMessage(dvb_diseqc_master_cmd &cmd);37 38 34 bool ToneVoltageLnb(DVBTuning& tuning, bool reset, bool& havetuned); 39 35 bool ToneSwitch(DVBTuning& tuning, bool reset, bool& havetuned); 36 37 bool SendDiSEqCPrepareBus(DVBTuning& tuning, bool reset); 38 bool SendDiSEqCMessage(DVBTuning& tuning, dvb_diseqc_master_cmd &cmd); 39 bool SendDiSEqCSetupBus(DVBTuning& tuning); 40 40 41 bool Diseqc1xSwitch(DVBTuning& tuning, bool reset, bool& havetuned, 41 42 uint ports); 42 43 bool PositionerGoto(DVBTuning& tuning, bool reset, bool& havetuned); 44 bool PositionerGotoAngular(DVBTuning& tuning, bool reset, 45 bool& havetuned); 46 /* 47 //currently not used 43 48 bool PositionerStore(DVBTuning& tuning); 44 49 bool PositionerStopMovement(); 45 50 bool PositionerStoreEastLimit(); 46 51 bool PositionerStoreWestLimit(); 47 bool PositionerDisableLimits(); 52 bool PositionerDisableLimits(); 48 53 bool PositionerDriveEast(int timestep); 49 54 bool PositionerDriveWest(int timestep); 50 bool PositionerGotoAngular(DVBTuning& tuning, bool reset,51 bool& havetuned);52 53 55 // Still need to be written 54 56 bool Positioner_Status(); 57 */ 55 58 56 59 enum diseqc_cmd_bytes { 57 60 FRAME = 0x0, … … 72 75 REPLY_CRCERR_RPT = 0xe6, 73 76 REPLY_CMDERR_RPT = 0xe7 74 77 }; 75 78 76 79 enum diseqc_address { 77 80 MASTER_TO_ALL = 0x00, 78 81 MASTER_TO_LSS = 0x10, -
libs/libmythtv/videosource.cpp
diff -Naur mythtv/libs/libmythtv/videosource.cpp mythtv-diseqc/libs/libmythtv/videosource.cpp
old new 1238 1238 addSelection("DiSEqC v1.2 Positioner","6"); 1239 1239 addSelection("DiSEqC v1.3 Positioner (Goto X)","7"); 1240 1240 addSelection("DiSEqC v1.1 or 2.1 (10-way method2)","8"); 1241 addSelection("DiSEqC v1.2 Positioner with a DiSEqC switch behind it.","10"); 1242 addSelection("DiSEqC v1.3 Positioner (Goto X) with a DiSEqC switch behind it.","11"); 1241 1243 setHelpText(QObject::tr("Select the input type for DVB-S cards. " 1242 1244 "Leave as Single LNB/Input for DVB-C or DVB-T. " 1243 1245 "The inputs are mapped from Input Connections option " … … 1683 1685 { 1684 1686 setLabel(QObject::tr("DiSEqC Satellite Location")); 1685 1687 setValue("0.0"); 1686 setHelpText(QObject::tr(" The longitude of the satellite"1687 " you are aiming at. For western hemisphere use "1688 " a negative value. Value is in decimal."));1688 setHelpText(QObject::tr("For 1.2 positioner enter the number as it is stored in the positioner for this satellite" 1689 "or for the GotoX (DiSEqC 1.3/USALS) positioner, this is a longitude of the satellite " 1690 "you are aiming at. For western hemisphere use a negative value. Value is in decimal.")); 1689 1691 // setVisible(false); 1690 1692 }; 1691 1693 // void fillSelections(const QString& pos) { … … 1708 1710 }; 1709 1711 1710 1712 1713 class DiSEqCPortPos: public SpinBoxSetting, public CISetting { 1714 public: 1715 DiSEqCPortPos(const CardInput& parent): 1716 SpinBoxSetting(0,4,0), 1717 CISetting(parent, "diseqc_port") { 1718 setLabel(QObject::tr("DiSEqC Port")); 1719 setValue(0); 1720 setHelpText(QObject::tr("Port umber of a DiSEqC switch " 1721 "behind a positioner. ")); 1722 }; 1723 }; 1724 1725 1711 1726 class FreeToAir: public CheckBoxSetting, public CISetting { 1712 1727 public: 1713 1728 FreeToAir(const CardInput& parent): … … 1880 1895 { 1881 1896 group->addChild(diseqcpos = new DiSEqCPos(*this)); 1882 1897 group->addChild(diseqcport = new DiSEqCPort(*this)); 1898 group->addChild(diseqcportpos = new DiSEqCPortPos(*this)); 1883 1899 group->addChild(lnblofswitch = new LNBLofSwitch(*this)); 1884 1900 group->addChild(lnblofhi = new LNBLofHi(*this)); 1885 1901 group->addChild(lnbloflo = new LNBLofLo(*this)); … … 1990 2006 { 1991 2007 if (dvbType == CardUtil::QPSK) 1992 2008 { 1993 //Check for DiSEqC type 1994 diseqcpos->setVisible(true); 1995 lnblofswitch->setVisible(true); 1996 lnbloflo->setVisible(true); 1997 lnblofhi->setVisible(true); 1998 if (CardUtil::GetDISEqCType(_cardid) == CardUtil::POSITIONER_X) 1999 diseqcpos->setEnabled(true); 2000 else 2001 diseqcpos->setEnabled(false); 2002 } 2003 else 2004 { 2005 diseqcpos->setVisible(false); 2006 lnblofswitch->setVisible(false); 2007 lnbloflo->setVisible(false); 2008 lnblofhi->setVisible(false); 2009 //Check for DiSEqC type 2010 diseqcpos->setVisible(true); 2011 diseqcportpos->setVisible(true); 2012 lnblofswitch->setVisible(true); 2013 lnbloflo->setVisible(true); 2014 lnblofhi->setVisible(true); 2015 if (CardUtil::GetDISEqCType(_cardid) == CardUtil::POSITIONER_1_2 || 2016 CardUtil::GetDISEqCType(_cardid) == CardUtil::POSITIONER_1_2_SWITCH || 2017 CardUtil::GetDISEqCType(_cardid) == CardUtil::POSITIONER_X || 2018 CardUtil::GetDISEqCType(_cardid) == CardUtil::POSITIONER_X_SWITCH) 2019 { 2020 diseqcpos->setEnabled(true); 2021 diseqcportpos->setEnabled(true); 2022 } 2023 else 2024 { 2025 diseqcpos->setEnabled(false); 2026 diseqcportpos->setEnabled(false); 2027 } 2028 } 2029 else 2030 { 2031 diseqcpos->setVisible(false); 2032 diseqcportpos->setVisible(false); 2033 lnblofswitch->setVisible(false); 2034 lnbloflo->setVisible(false); 2035 lnblofhi->setVisible(false); 2009 2036 } 2010 2037 } 2011 2038 } … … 2429 2456 list.append(DVBDiSEqCInputList( 2430 2457 stxt.arg(i+1,2), QString::number(i), "")); 2431 2458 break; 2459 case 10: 2460 for (i = 1; i < 50; ++i) 2461 list.append(DVBDiSEqCInputList( 2462 mtxt.arg(i), "", QString::number(i))); 2463 break; 2464 case 11: 2465 for (i = 1; i < 100; ++i) 2466 list.append(DVBDiSEqCInputList( 2467 itxt.arg(i), "", QString::number(i))); 2468 break; 2469 2432 2470 default: 2433 2471 list.append(DVBDiSEqCInputList( 2434 2472 QString("DVBInput"), QString(""), QString(""))); -
libs/libmythtv/videosource.h
diff -Naur mythtv/libs/libmythtv/videosource.h mythtv-diseqc/libs/libmythtv/videosource.h
old new 53 53 POSITIONER_X, 54 54 POSITIONER_1_2_SWITCH_2, 55 55 POSITIONER_X_SWITCH_2, 56 POSITIONER_1_2_SWITCH, 57 POSITIONER_X_SWITCH, 56 58 }; 57 59 /// \brief dvb card type 58 60 static const QString DVB; … … 522 524 class DVBLNBChooser; 523 525 class DiSEqCPos; 524 526 class DiSEqCPort; 527 class DiSEqCPortPos; 525 528 class LNBLofSwitch; 526 529 class LNBLofLo; 527 530 class LNBLofHi; … … 573 576 DVBLNBChooser *lnbsettings; 574 577 DiSEqCPos *diseqcpos; 575 578 DiSEqCPort *diseqcport; 579 DiSEqCPortPos *diseqcportpos; 576 580 LNBLofSwitch *lnblofswitch; 577 581 LNBLofLo *lnbloflo; 578 582 LNBLofHi *lnblofhi;