summaryrefslogtreecommitdiffstats
path: root/abs/extra-testing/community/mythtv-contrib/6200ch.c.r21651.patch
blob: f883ecbefd731c146013b983b468ee3a760843c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
--- contrib/channel_changers/6200ch/6200ch.c.orig	2009-09-03 19:51:11.913853152 +0000
+++ contrib/channel_changers/6200ch/6200ch.c	2009-09-04 05:11:44.212465932 +0000
@@ -88,6 +88,9 @@
 #define QIP7100_MODEL_ID1  0x00008100
 #define QIP7100_MODEL_ID2  0x00000001
 
+#define QIP6200_VENDOR_ID1 0x0000211e
+#define QIP6200_MODEL_ID1  0x00007100
+
 #define MOT_UNKNOWN_VENDOR_ID1 0x04db
 #define MOT_UNKNOWN_VENDOR_ID2 0x0406
 #define MOT_UNKNOWN_VENDOR_ID3 0x0ce5
@@ -99,17 +102,16 @@
 #define MOT_UNKNOWN_VENDOR_ID9 0x1ade
 #define MOT_UNKNOWN_VENDOR_ID10 0x1cfb
 #define MOT_UNKNOWN_VENDOR_ID11 0x2040
-#define MOT_UNKNOWN_VENDOR_ID12 0x211e
-#define MOT_UNKNOWN_VENDOR_ID13 0x2180
-#define MOT_UNKNOWN_VENDOR_ID14 0x2210
-#define MOT_UNKNOWN_VENDOR_ID15 0x230b
-#define MOT_UNKNOWN_VENDOR_ID16 0x2375
-#define MOT_UNKNOWN_VENDOR_ID17 0x2395
-#define MOT_UNKNOWN_VENDOR_ID18 0x23a2
-#define MOT_UNKNOWN_VENDOR_ID19 0x23ed
-#define MOT_UNKNOWN_VENDOR_ID20 0x23ee
-#define MOT_UNKNOWN_VENDOR_ID21 0x23a0
-#define MOT_UNKNOWN_VENDOR_ID22 0x23a1
+#define MOT_UNKNOWN_VENDOR_ID12 0x2180
+#define MOT_UNKNOWN_VENDOR_ID13 0x2210
+#define MOT_UNKNOWN_VENDOR_ID14 0x230b
+#define MOT_UNKNOWN_VENDOR_ID15 0x2375
+#define MOT_UNKNOWN_VENDOR_ID16 0x2395
+#define MOT_UNKNOWN_VENDOR_ID17 0x23a2
+#define MOT_UNKNOWN_VENDOR_ID18 0x23ed
+#define MOT_UNKNOWN_VENDOR_ID19 0x23ee
+#define MOT_UNKNOWN_VENDOR_ID20 0x23a0
+#define MOT_UNKNOWN_VENDOR_ID21 0x23a1
 
 #define PACE_VENDOR_ID1    0x00005094 /* 550 & 779 */
 #define PACE_VENDOR_ID2    0x00005094 /* unknown */
@@ -128,21 +130,23 @@
 #define RETRY_COUNT_FAST 0
 
 void set_chan_slow(raw1394handle_t handle, int device, int verbose, int chn);
+void set_chan_slow_four_digit(raw1394handle_t handle, int device, int verbose, int chn);
 void set_chan_fast(raw1394handle_t handle, int device, int verbose, int chn);
 void set_power_fast(raw1394handle_t handle, int device, int verbose);
 
 void usage()
 {
    fprintf(stderr, "Usage: 6200ch [-v] [-s] [-n NODE] [-g GUID] [-p PORT] "
-           "<channel_num>\n");
+           "[-4] <channel_num>\n");
    fprintf(stderr, "-v        print additional verbose output\n");
-   fprintf(stderr, "-s        use single packet method\n");
+   fprintf(stderr, "-s        use single packet method. Cannot be used with -4.\n");
    fprintf(stderr, "-w        toggle power state\n");
    fprintf(stderr, "-n NODE   node to start device scanning on (default:%i)\n",
            STARTING_NODE);
    fprintf(stderr, "-p PORT   port/adapter to use              (default:%i)\n",
            STARTING_PORT);
    fprintf(stderr, "-g GUID   GUID to use, -n switch, if present, will be ignored.\n");
+   fprintf(stderr, "-4        Enable 4 digit channel number support. Cannot be used with -s.\n");
    exit(1);
 }
 
@@ -158,6 +162,7 @@
    octlet_t cli_GUID=0LL;
    octlet_t node_GUID=0LL;
    int chn = 0;
+   int use_four_digit = 0;
 
    /* some people experience crashes when starting on node 1 */
    int starting_node = STARTING_NODE;
@@ -168,7 +173,7 @@
       usage();
 
    opterr = 0;
-   while ((c = getopt(argc, argv, "vswg:n:p:")) != -1)
+   while ((c = getopt(argc, argv, "vswg:n:p:4")) != -1)
    {
        switch (c) {
        case 'v':
@@ -191,16 +196,24 @@
        case 'p':
            starting_port = atoi(optarg);
            break;
+       case '4':
+           use_four_digit = 1;
+           break;
        default:
            fprintf(stderr, "incorrect command line arguments\n");
            usage();
        }
    }
 
+   {
+   /* We cannot use single packet with 4 digits */
+       if (single_packet && use_four_digit)
+           usage();
+   }
    /* print out usage message if not enough arguments */
    if (optind == argc-1)
    {
-       /* the last argument is the channel number */
+   /* the last argument is the channel number */
        chn = atoi(argv[optind]);
    }
    else if (!toggle_power)
@@ -292,6 +305,7 @@
             (dir.vendor_id == DCT6416_VENDOR_ID1) ||
             (dir.vendor_id == DCT6416_VENDOR_ID2) ||
             (dir.vendor_id == QIP7100_VENDOR_ID1) ||
+            (dir.vendor_id == QIP6200_VENDOR_ID1) ||
             (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID1) ||
             (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID2) ||
             (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID3) ||
@@ -313,7 +327,6 @@
             (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID19) ||
             (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID20) ||
             (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID21) ||
-            (dir.vendor_id == MOT_UNKNOWN_VENDOR_ID22) ||
             (dir.vendor_id == PACE_VENDOR_ID1) ||
             (dir.vendor_id == PACE_VENDOR_ID2)) &&
            ((dir.model_id == DCH3200_MODEL_ID1) ||
@@ -330,6 +343,7 @@
             (dir.model_id == DCT6416_MODEL_ID1) ||
             (dir.model_id == QIP7100_MODEL_ID1) ||
             (dir.model_id == QIP7100_MODEL_ID2) ||
+            (dir.model_id == QIP6200_MODEL_ID1) ||
             (dir.model_id == PACE550_MODEL_ID1) ||
             (dir.model_id == PACE779_MODEL_ID1)) )
       {
@@ -356,6 +370,9 @@
        if (single_packet)
            set_chan_fast(handle, device, verbose, chn);
        else
+       if (use_four_digit)
+           set_chan_slow_four_digit(handle, device, verbose, chn); 
+       else
            set_chan_slow(handle, device, verbose, chn);
    }
 
@@ -387,6 +404,37 @@
    }
 }
 
+// Same as set_chan_slow(), but sends 4 digits instead of 3 (for quicker channel changes on QIP6200-2 / QIP7100-1)
+void set_chan_slow_four_digit(raw1394handle_t handle, int device, int verbose, int chn)
+{
+   int i;
+   int dig[4];
+   quadlet_t cmd[2];
+
+   if (verbose)
+       printf("chn: %d\n", chn);
+
+   dig[3] = (chn % 10);
+   dig[2] = (chn % 100) / 10;
+   dig[1] = (chn % 1000) / 100;
+   dig[0] = (chn % 10000) / 1000;
+
+   if (verbose)
+      printf("AV/C Command: %d%d%d%d = Op1=0x%08X Op2=0x%08X Op3=0x%08X Op4=0x%08X\n",
+            dig[0], dig[1], dig[2], dig[3],
+            CTL_CMD0 | dig[0], CTL_CMD0 | dig[1], CTL_CMD0 | dig[2], CTL_CMD0 | dig[3]);
+
+   for (i=0; i<4; i++) {
+      if (verbose)
+          printf("Sending digit %d\n", dig[i]);
+      cmd[0] = CTL_CMD0 | dig[i];
+      cmd[1] = 0x0;
+    
+      avc1394_transaction_block(handle, device, cmd, 2, RETRY_COUNT_SLOW);
+      usleep(500000); // small delay for button to register
+   }
+} 
+
 void set_chan_fast(raw1394handle_t handle, int device, int verbose, int chn)
 {
     quadlet_t cmd[3];