Ticket #4924: 6200_pace_power.diff

File 6200_pace_power.diff, 6.8 KB (added by bmayland@…, 13 years ago)

Patch against r16508

  • contrib/channel_changers/6200ch/6200ch.c

     
    7676#define DCT6416_VENDOR_ID2 0x00001a66
    7777#define DCT6416_MODEL_ID1  0x0000646b
    7878
    79 #define AVC1394_SUBUNIT_TYPE_6200 (9 << 19)  /* uses a reserved subunit type */
     79#define PACE550_VENDOR_ID1 0x00005094
     80#define PACE550_MODEL_ID1  0x00010551
    8081
    81 #define AVC1394_6200_COMMAND_CHANNEL 0x000007C00   /* 6200 subunit command */
    8282#define AVC1394_6200_OPERAND_SET 0x20      /* 6200 subunit command operand */
    8383
    84 #define CTL_CMD0 AVC1394_CTYPE_CONTROL | AVC1394_SUBUNIT_TYPE_6200 | \
    85         AVC1394_SUBUNIT_ID_0 | AVC1394_6200_COMMAND_CHANNEL | \
     84#define CTL_CMD0 AVC1394_CTYPE_CONTROL | AVC1394_SUBUNIT_TYPE_PANEL | \
     85        AVC1394_SUBUNIT_ID_0 | AVC1394_PANEL_COMMAND_PASS_THROUGH | \
    8686        AVC1394_6200_OPERAND_SET
    8787
    8888#define STARTING_NODE 1  /* skip 1394 nodes to avoid error msgs */
     
    9292
    9393void set_chan_slow(raw1394handle_t handle, int device, int verbose, int chn);
    9494void set_chan_fast(raw1394handle_t handle, int device, int verbose, int chn);
     95void set_power_fast(raw1394handle_t handle, int device, int verbose);
    9596
    9697void usage()
    9798{
     
    99100           "<channel_num>\n");
    100101   fprintf(stderr, "-v        print additional verbose output\n");
    101102   fprintf(stderr, "-s        use single packet method\n");
     103   fprintf(stderr, "-w        toggle power state\n");
    102104   fprintf(stderr, "-n NODE   node to start device scanning on (default:%i)\n",
    103105           STARTING_NODE);
    104106   fprintf(stderr, "-p PORT   port/adapter to use              (default:%i)\n",
     
    114116   int i;
    115117   int verbose = 0;
    116118   int single_packet = 0;
     119   int toggle_power = 0;
    117120   int bGUID=0;
    118121   octlet_t cli_GUID=0LL;
    119122   octlet_t node_GUID=0LL;
    120    quadlet_t cmd[2];
    121    int chn = 550;
     123   int chn = 0;
    122124
    123125   /* some people experience crashes when starting on node 1 */
    124126   int starting_node = STARTING_NODE;
    125127   int starting_port = STARTING_PORT;
    126128   int c;
    127    int index;
    128129
    129130   if (argc < 2)
    130131      usage();
    131132
    132133   opterr = 0;
    133    while ((c = getopt(argc, argv, "vsg:n:p:")) != -1)
     134   while ((c = getopt(argc, argv, "vswg:n:p:")) != -1)
    134135   {
    135136       switch (c) {
    136137       case 'v':
     
    139140       case 's':
    140141           single_packet = 1;
    141142           break;
     143       case 'w':
     144           toggle_power = 1;
     145           break;
    142146       case 'n':
    143147           starting_node = atoi(optarg);
    144148           break;
     
    157161   }
    158162
    159163   /* print out usage message if not enough arguments */
    160    if (optind != argc-1) {
     164   if (optind == argc-1) {
     165       /* the last argument is the channel number */
     166       chn = atoi(argv[optind]);
     167   } else if (!toggle_power) {
    161168       usage();
    162169   }
    163    /* the last argument is the channel number */
    164    chn = atoi(argv[optind]);
    165170
    166171#ifdef RAW1394_V_0_8
    167172   raw1394handle_t handle = raw1394_get_handle();
     
    239244            (dir.vendor_id == DCT6200_VENDOR_ID15) ||
    240245            (dir.vendor_id == DCT6412_VENDOR_ID1) ||
    241246            (dir.vendor_id == DCT6412_VENDOR_ID2) ||
    242             (dir.vendor_id == DCT6416_VENDOR_ID1) ||
    243             (dir.vendor_id == DCT6416_VENDOR_ID2)) &&
     247            (dir.vendor_id == DCT6416_VENDOR_ID1) ||
     248            (dir.vendor_id == DCT6416_VENDOR_ID2) ||
     249            (dir.vendor_id == PACE550_VENDOR_ID1)
     250            ) &&
    244251           ((dir.model_id == DCH3200_MODEL_ID1) ||
    245252            (dir.model_id == DCT3412_MODEL_ID1) ||
    246253            (dir.model_id == DCT3416_MODEL_ID1) ||
     
    250257            (dir.model_id == DCT6200_MODEL_ID2) ||
    251258            (dir.model_id == DCT6412_MODEL_ID1) ||
    252259            (dir.model_id == DCT6412_MODEL_ID2) ||
     260            (dir.model_id == PACE550_MODEL_ID1) ||
    253261            (dir.model_id == DCT6416_MODEL_ID1)) ) {
    254262            if (dir.unit_spec_id != DCT6200_SPEC_ID)
    255                fprintf(stderr, "Warning: Unit Spec ID different.\n");
     263               fprintf(stderr, "Warning: Unit Spec ID 0x%x different.\n", dir.unit_spec_id);
    256264            if (dir.unit_sw_version != DCT6200_SW_VERSION)
    257                fprintf(stderr, "Warning: Unit Software Version different.\n");
     265               fprintf(stderr, "Warning: Unit Software Version 0x%x different.\n", dir.unit_sw_version);
    258266            device = i;
    259267            break;
    260268      }
     
    266274        exit(1);
    267275   }
    268276
    269    if (single_packet)
    270        set_chan_fast(handle, device, verbose, chn);
    271    else
    272        set_chan_slow(handle, device, verbose, chn);
     277   if (toggle_power)
     278       set_power_fast(handle, device, verbose);
    273279
     280   if (chn) {
     281       if (single_packet)
     282           set_chan_fast(handle, device, verbose, chn);
     283       else
     284           set_chan_slow(handle, device, verbose, chn);
     285   }
     286
    274287   raw1394_destroy_handle(handle);
    275288   exit(0);
    276289}
     
    280293   int i;
    281294   int dig[3];
    282295   quadlet_t cmd[2];
     296   quadlet_t *response;
    283297
    284298   dig[2] = (chn % 10);
    285299   dig[1] = (chn % 100)  / 10;
     
    294308      cmd[0] = CTL_CMD0 | dig[i];
    295309      cmd[1] = 0x0;
    296310   
    297       avc1394_transaction_block(handle, device, cmd, 2, RETRY_COUNT_SLOW);
     311      response = avc1394_transaction_block(handle, device, cmd, 2, RETRY_COUNT_FAST);
     312      if (verbose) {
     313          if (NULL != response)
     314              printf("  (%x) 0x%x\n", (*response) >> 24, *response);
     315          else
     316              printf("  No response\n");
     317      }
     318
    298319      usleep(500000);  // small delay for button to register
    299320   }
    300321}
     
    302323void set_chan_fast(raw1394handle_t handle, int device, int verbose, int chn)
    303324{
    304325    quadlet_t cmd[3];
     326    quadlet_t *response;
    305327
    306328    cmd[0] = CTL_CMD0 | 0x67;
    307329    cmd[1] = (0x04 << 24) | (chn << 8) | 0x000000FF;
    308330    cmd[2] = 0xFF << 24;
    309331
    310     if (verbose)
     332    response = avc1394_transaction_block(handle, device, cmd, 3, RETRY_COUNT_FAST);
     333
     334    if (verbose) {
    311335        printf("AV/C command for channel %d = 0x%08X %08X %08X\n",
    312336               chn, cmd[0], cmd[1], cmd[2]);
    313  
    314     avc1394_transaction_block(handle, device, cmd, 3, RETRY_COUNT_FAST);
     337        if (NULL != response)
     338          printf("  (%x) 0x%x\n", (*response) >> 24, *response);
     339        else
     340          printf("  No response\n");
     341    }
    315342}
    316343
     344void set_power_fast(raw1394handle_t handle, int device, int verbose)
     345{
     346    quadlet_t cmd[2];
     347    quadlet_t *response;
     348
     349    cmd[0] = (CTL_CMD0 & 0xffffff00) | AVC1394_PANEL_OPERATION_POWER;
     350    cmd[1] = 0;
     351
     352    response = avc1394_transaction_block(handle, device, cmd, 2, RETRY_COUNT_FAST);
     353
     354    if (verbose) {
     355        printf("AV/C command for power = 0x%08X\n", cmd[0]);
     356        if (NULL != response)
     357          printf("  (%x) 0x%x\n", (*response) >> 24, *response);
     358        else
     359          printf("  No response\n");
     360    }
     361}
     362
    317363/* vim: set expandtab tabstop=4 shiftwidth=4: */