Ticket #6977: 6200ch.c.r21651.patch

File 6200ch.c.r21651.patch, 6.3 KB (added by hansonorders@…, 10 years ago)
  • contrib/channel_changers/6200ch/6200ch.c

    old new  
    8888#define QIP7100_MODEL_ID1  0x00008100
    8989#define QIP7100_MODEL_ID2  0x00000001
    9090
     91#define QIP6200_VENDOR_ID1 0x0000211e
     92#define QIP6200_MODEL_ID1  0x00007100
     93
    9194#define MOT_UNKNOWN_VENDOR_ID1 0x04db
    9295#define MOT_UNKNOWN_VENDOR_ID2 0x0406
    9396#define MOT_UNKNOWN_VENDOR_ID3 0x0ce5
     
    99102#define MOT_UNKNOWN_VENDOR_ID9 0x1ade
    100103#define MOT_UNKNOWN_VENDOR_ID10 0x1cfb
    101104#define MOT_UNKNOWN_VENDOR_ID11 0x2040
    102 #define MOT_UNKNOWN_VENDOR_ID12 0x211e
    103 #define MOT_UNKNOWN_VENDOR_ID13 0x2180
    104 #define MOT_UNKNOWN_VENDOR_ID14 0x2210
    105 #define MOT_UNKNOWN_VENDOR_ID15 0x230b
    106 #define MOT_UNKNOWN_VENDOR_ID16 0x2375
    107 #define MOT_UNKNOWN_VENDOR_ID17 0x2395
    108 #define MOT_UNKNOWN_VENDOR_ID18 0x23a2
    109 #define MOT_UNKNOWN_VENDOR_ID19 0x23ed
    110 #define MOT_UNKNOWN_VENDOR_ID20 0x23ee
    111 #define MOT_UNKNOWN_VENDOR_ID21 0x23a0
    112 #define MOT_UNKNOWN_VENDOR_ID22 0x23a1
     105#define MOT_UNKNOWN_VENDOR_ID12 0x2180
     106#define MOT_UNKNOWN_VENDOR_ID13 0x2210
     107#define MOT_UNKNOWN_VENDOR_ID14 0x230b
     108#define MOT_UNKNOWN_VENDOR_ID15 0x2375
     109#define MOT_UNKNOWN_VENDOR_ID16 0x2395
     110#define MOT_UNKNOWN_VENDOR_ID17 0x23a2
     111#define MOT_UNKNOWN_VENDOR_ID18 0x23ed
     112#define MOT_UNKNOWN_VENDOR_ID19 0x23ee
     113#define MOT_UNKNOWN_VENDOR_ID20 0x23a0
     114#define MOT_UNKNOWN_VENDOR_ID21 0x23a1
    113115
    114116#define PACE_VENDOR_ID1    0x00005094 /* 550 & 779 */
    115117#define PACE_VENDOR_ID2    0x00005094 /* unknown */
     
    128130#define RETRY_COUNT_FAST 0
    129131
    130132void set_chan_slow(raw1394handle_t handle, int device, int verbose, int chn);
     133void set_chan_slow_four_digit(raw1394handle_t handle, int device, int verbose, int chn);
    131134void set_chan_fast(raw1394handle_t handle, int device, int verbose, int chn);
    132135void set_power_fast(raw1394handle_t handle, int device, int verbose);
    133136
    134137void usage()
    135138{
    136139   fprintf(stderr, "Usage: 6200ch [-v] [-s] [-n NODE] [-g GUID] [-p PORT] "
    137            "<channel_num>\n");
     140           "[-4] <channel_num>\n");
    138141   fprintf(stderr, "-v        print additional verbose output\n");
    139    fprintf(stderr, "-s        use single packet method\n");
     142   fprintf(stderr, "-s        use single packet method. Cannot be used with -4.\n");
    140143   fprintf(stderr, "-w        toggle power state\n");
    141144   fprintf(stderr, "-n NODE   node to start device scanning on (default:%i)\n",
    142145           STARTING_NODE);
    143146   fprintf(stderr, "-p PORT   port/adapter to use              (default:%i)\n",
    144147           STARTING_PORT);
    145148   fprintf(stderr, "-g GUID   GUID to use, -n switch, if present, will be ignored.\n");
     149   fprintf(stderr, "-4        Enable 4 digit channel number support. Cannot be used with -s.\n");
    146150   exit(1);
    147151}
    148152
     
    158162   octlet_t cli_GUID=0LL;
    159163   octlet_t node_GUID=0LL;
    160164   int chn = 0;
     165   int use_four_digit = 0;
    161166
    162167   /* some people experience crashes when starting on node 1 */
    163168   int starting_node = STARTING_NODE;
     
    168173      usage();
    169174
    170175   opterr = 0;
    171    while ((c = getopt(argc, argv, "vswg:n:p:")) != -1)
     176   while ((c = getopt(argc, argv, "vswg:n:p:4")) != -1)
    172177   {
    173178       switch (c) {
    174179       case 'v':
     
    191196       case 'p':
    192197           starting_port = atoi(optarg);
    193198           break;
     199       case '4':
     200           use_four_digit = 1;
     201           break;
    194202       default:
    195203           fprintf(stderr, "incorrect command line arguments\n");
    196204           usage();
    197205       }
    198206   }
    199207
     208   {
     209   /* We cannot use single packet with 4 digits */
     210       if (single_packet && use_four_digit)
     211           usage();
     212   }
    200213   /* print out usage message if not enough arguments */
    201214   if (optind == argc-1)
    202215   {
    203        /* the last argument is the channel number */
     216   /* the last argument is the channel number */
    204217       chn = atoi(argv[optind]);
    205218   }
    206219   else if (!toggle_power)
     
    292305            (dir.vendor_id == DCT6416_VENDOR_ID1) ||
    293306            (dir.vendor_id == DCT6416_VENDOR_ID2) ||
    294307            (dir.vendor_id == QIP7100_VENDOR_ID1) ||
     308            (dir.vendor_id == QIP6200_VENDOR_ID1) ||
    295309            (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID1) ||
    296310            (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID2) ||
    297311            (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID3) ||
     
    313327            (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID19) ||
    314328            (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID20) ||
    315329            (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID21) ||
    316             (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID22) ||
    317330            (dir.vendor_id == PACE_VENDOR_ID1) ||
    318331            (dir.vendor_id == PACE_VENDOR_ID2)) &&
    319332           ((dir.model_id == DCH3200_MODEL_ID1) ||
     
    330343            (dir.model_id == DCT6416_MODEL_ID1) ||
    331344            (dir.model_id == QIP7100_MODEL_ID1) ||
    332345            (dir.model_id == QIP7100_MODEL_ID2) ||
     346            (dir.model_id == QIP6200_MODEL_ID1) ||
    333347            (dir.model_id == PACE550_MODEL_ID1) ||
    334348            (dir.model_id == PACE779_MODEL_ID1)) )
    335349      {
     
    356370       if (single_packet)
    357371           set_chan_fast(handle, device, verbose, chn);
    358372       else
     373       if (use_four_digit)
     374           set_chan_slow_four_digit(handle, device, verbose, chn);
     375       else
    359376           set_chan_slow(handle, device, verbose, chn);
    360377   }
    361378
     
    387404   }
    388405}
    389406
     407// Same as set_chan_slow(), but sends 4 digits instead of 3 (for quicker channel changes on QIP6200-2 / QIP7100-1)
     408void set_chan_slow_four_digit(raw1394handle_t handle, int device, int verbose, int chn)
     409{
     410   int i;
     411   int dig[4];
     412   quadlet_t cmd[2];
     413
     414   if (verbose)
     415       printf("chn: %d\n", chn);
     416
     417   dig[3] = (chn % 10);
     418   dig[2] = (chn % 100) / 10;
     419   dig[1] = (chn % 1000) / 100;
     420   dig[0] = (chn % 10000) / 1000;
     421
     422   if (verbose)
     423      printf("AV/C Command: %d%d%d%d = Op1=0x%08X Op2=0x%08X Op3=0x%08X Op4=0x%08X\n",
     424            dig[0], dig[1], dig[2], dig[3],
     425            CTL_CMD0 | dig[0], CTL_CMD0 | dig[1], CTL_CMD0 | dig[2], CTL_CMD0 | dig[3]);
     426
     427   for (i=0; i<4; i++) {
     428      if (verbose)
     429          printf("Sending digit %d\n", dig[i]);
     430      cmd[0] = CTL_CMD0 | dig[i];
     431      cmd[1] = 0x0;
     432   
     433      avc1394_transaction_block(handle, device, cmd, 2, RETRY_COUNT_SLOW);
     434      usleep(500000); // small delay for button to register
     435   }
     436}
     437
    390438void set_chan_fast(raw1394handle_t handle, int device, int verbose, int chn)
    391439{
    392440    quadlet_t cmd[3];