519
|
1 |
diff -ur libavc1394-0.5.3.orig/libavc1394/avc1394.h libavc1394-0.5.3/libavc1394/avc1394.h
|
|
2 |
--- libavc1394-0.5.3.orig/libavc1394/avc1394.h 2006-05-22 07:11:14.000000000 +0700
|
|
3 |
+++ libavc1394-0.5.3/libavc1394/avc1394.h 2007-09-30 21:03:19.658948532 +0700
|
|
4 |
@@ -24,6 +24,7 @@
|
|
5 |
|
|
6 |
|
|
7 |
#include <libraw1394/raw1394.h>
|
|
8 |
+#include <libraw1394/solaris.h>
|
|
9 |
|
|
10 |
/* AV/C response codes */
|
|
11 |
#define AVC1394_RESPONSE_NOT_IMPLEMENTED 0x08000000
|
|
12 |
diff -ur libavc1394-0.5.3.orig/libavc1394/avc1394_simple.c libavc1394-0.5.3/libavc1394/avc1394_simple.c
|
|
13 |
--- libavc1394-0.5.3.orig/libavc1394/avc1394_simple.c 2006-04-13 23:16:41.000000000 +0700
|
|
14 |
+++ libavc1394-0.5.3/libavc1394/avc1394_simple.c 2007-09-30 21:03:27.419832101 +0700
|
|
15 |
@@ -37,46 +37,152 @@
|
|
16 |
#include "avc1394_internal.h"
|
|
17 |
#include "../common/raw1394util.h"
|
|
18 |
|
|
19 |
-/* For select() */
|
|
20 |
-#include <sys/time.h>
|
|
21 |
+#include <sys/1394/ieee1394.h>
|
|
22 |
+#include <sys/av/iec61883.h>
|
|
23 |
+#include <sys/stat.h>
|
|
24 |
#include <sys/types.h>
|
|
25 |
+#include <netinet/in.h>
|
|
26 |
+#include <assert.h>
|
|
27 |
+#include <errno.h>
|
|
28 |
+#include <fcntl.h>
|
|
29 |
+#include <inttypes.h>
|
|
30 |
+#include <sys/time.h>
|
|
31 |
#include <sys/poll.h>
|
|
32 |
#include <unistd.h>
|
|
33 |
#include <time.h>
|
|
34 |
#include <string.h>
|
|
35 |
-#include <netinet/in.h>
|
|
36 |
#include <stdlib.h>
|
|
37 |
|
|
38 |
#ifdef DEBUG
|
|
39 |
#include <stdio.h>
|
|
40 |
#endif
|
|
41 |
|
|
42 |
+extern int errno;
|
|
43 |
|
|
44 |
-int avc1394_send_command(raw1394handle_t handle, nodeid_t node, quadlet_t command)
|
|
45 |
-{
|
|
46 |
- quadlet_t cmd = htonl(command);
|
|
47 |
+/*
|
|
48 |
+ * Send an AV/C quadlet command.
|
|
49 |
+ * On failure, returns -1 with errno set.
|
|
50 |
+ */
|
|
51 |
|
|
52 |
- return cooked1394_write(handle, 0xffc0 | node, FCP_COMMAND_ADDR, sizeof(quadlet_t), &cmd);
|
|
53 |
+int
|
|
54 |
+avc1394_send_command(raw1394handle_t handle, nodeid_t node, quadlet_t command)
|
|
55 |
+{
|
|
56 |
+ int fd;
|
|
57 |
+ iec61883_arq_t arq;
|
|
58 |
+ ssize_t ssz;
|
|
59 |
+ fd = solaris_get_fd(handle, node, 1);
|
|
60 |
+ if (fd < 0)
|
|
61 |
+ return -1;
|
|
62 |
+
|
|
63 |
+ arq.arq_type = IEC61883_ARQ_FCP_CMD;
|
|
64 |
+ arq.arq_len = IEEE1394_QUADLET;
|
|
65 |
+ arq.arq_data.quadlet = htonl(command);
|
|
66 |
+
|
|
67 |
+again:
|
|
68 |
+ ssz = write(fd, &arq, sizeof (arq));
|
|
69 |
+ if (ssz == sizeof (arq))
|
|
70 |
+ return 0;
|
|
71 |
+
|
|
72 |
+ if (ssz != -1)
|
|
73 |
+ solaris_bad_error(__FILE__, __LINE__, "write", -1);
|
|
74 |
+
|
|
75 |
+ switch(errno) {
|
|
76 |
+ case EAGAIN:
|
|
77 |
+ case EDQUOT:
|
|
78 |
+ case EFBIG:
|
|
79 |
+ case EIO:
|
|
80 |
+ case ENOLCK:
|
|
81 |
+ case ENOLINK:
|
|
82 |
+ case ENOSPC:
|
|
83 |
+ case EPIPE:
|
|
84 |
+ case ERANGE:
|
|
85 |
+ case EINVAL:
|
|
86 |
+ solaris_close_fd(handle, node, 1);
|
|
87 |
+ errno = ENODEV;
|
|
88 |
+ return -1;
|
|
89 |
+
|
|
90 |
+ case ENOSR:
|
|
91 |
+ case ENXIO:
|
|
92 |
+ return -1;
|
|
93 |
+
|
|
94 |
+ case EINTR:
|
|
95 |
+ goto again;
|
|
96 |
+
|
|
97 |
+ case EBADF:
|
|
98 |
+ case EDEADLK:
|
|
99 |
+ case EFAULT:
|
|
100 |
+ default:
|
|
101 |
+ solaris_bad_error(__FILE__, __LINE__, "write", errno);
|
|
102 |
+ }
|
|
103 |
+#ifdef DEBUG
|
|
104 |
+ fprintf(stderr, "avc1394_send_command: ");
|
|
105 |
+ for (int i = 0; i < command_len; i++)
|
|
106 |
+ (void) fprintf(stderr, " 0x%08X", htonl(command[i]));
|
|
107 |
+ (void) fprintf(stderr, " (%s)\n", decode_ctype(command[0]));
|
|
108 |
+#endif
|
|
109 |
}
|
|
110 |
|
|
111 |
-int avc1394_send_command_block(raw1394handle_t handle, nodeid_t node,
|
|
112 |
+int
|
|
113 |
+avc1394_send_command_block(raw1394handle_t handle, nodeid_t node,
|
|
114 |
quadlet_t *command, int command_len)
|
|
115 |
{
|
|
116 |
- quadlet_t cmd[command_len];
|
|
117 |
- int i;
|
|
118 |
-
|
|
119 |
- for (i=0; i < command_len; i++) {
|
|
120 |
- cmd[i] = htonl(command[i]);
|
|
121 |
- }
|
|
122 |
-
|
|
123 |
-#ifdef DEBUG
|
|
124 |
- fprintf(stderr, "avc1394_send_command_block: ");
|
|
125 |
- for (i=0; i < command_len; i++)
|
|
126 |
- fprintf(stderr, " 0x%08X", htonl(command[i]));
|
|
127 |
- fprintf(stderr, " (%s)\n", decode_ctype(command[0]));
|
|
128 |
-#endif
|
|
129 |
- return cooked1394_write(handle, 0xffc0 | node, FCP_COMMAND_ADDR,
|
|
130 |
- command_len * sizeof(quadlet_t), cmd);
|
|
131 |
+ int fd;
|
|
132 |
+ iec61883_arq_t *arqp;
|
|
133 |
+ size_t asz;
|
|
134 |
+ ssize_t ssz;
|
|
135 |
+ uint32_t *ca;
|
|
136 |
+
|
|
137 |
+ fd = solaris_get_fd(handle, node, 1);
|
|
138 |
+ if (fd < 0)
|
|
139 |
+ return -1;
|
|
140 |
+
|
|
141 |
+ asz = sizeof (*arqp) - sizeof (arqp->arq_data) + command_len * 4;
|
|
142 |
+ arqp = malloc(asz);
|
|
143 |
+ if (arqp == NULL)
|
|
144 |
+ return -1;
|
|
145 |
+
|
|
146 |
+ arqp->arq_type = IEC61883_ARQ_FCP_CMD;
|
|
147 |
+ arqp->arq_len = command_len * 4;
|
|
148 |
+
|
|
149 |
+ ca = (quadlet_t *)&arqp->arq_data;
|
|
150 |
+ for (int i = 0; i < command_len; ++i)
|
|
151 |
+ ca[i] = htonl(command[i]);
|
|
152 |
+
|
|
153 |
+again:
|
|
154 |
+ ssz = write(fd, arqp, asz);
|
|
155 |
+ if (ssz == asz)
|
|
156 |
+ return 0;
|
|
157 |
+
|
|
158 |
+ if (ssz != -1)
|
|
159 |
+ solaris_bad_error(__FILE__, __LINE__, "write", -1);
|
|
160 |
+
|
|
161 |
+ switch(errno) {
|
|
162 |
+ case EAGAIN:
|
|
163 |
+ case EDQUOT:
|
|
164 |
+ case EFBIG:
|
|
165 |
+ case EIO:
|
|
166 |
+ case ENOLCK:
|
|
167 |
+ case ENOLINK:
|
|
168 |
+ case ENOSPC:
|
|
169 |
+ case EPIPE:
|
|
170 |
+ case ERANGE:
|
|
171 |
+ case EINVAL:
|
|
172 |
+ solaris_close_fd(handle, node, 1);
|
|
173 |
+ errno = ENODEV;
|
|
174 |
+ return -1;
|
|
175 |
+
|
|
176 |
+ case ENOSR:
|
|
177 |
+ case ENXIO:
|
|
178 |
+ return -1;
|
|
179 |
+
|
|
180 |
+ case EINTR:
|
|
181 |
+ goto again;
|
|
182 |
+
|
|
183 |
+ case EBADF:
|
|
184 |
+ case EDEADLK:
|
|
185 |
+ case EFAULT:
|
|
186 |
+ solaris_bad_error(__FILE__, __LINE__, "write", errno);
|
|
187 |
+ }
|
|
188 |
}
|
|
189 |
|
|
190 |
|
|
191 |
@@ -90,73 +196,54 @@
|
|
192 |
* RETURNS: the AV/C response if everything went well, -1 in case of an
|
|
193 |
* error
|
|
194 |
*/
|
|
195 |
-quadlet_t avc1394_transaction(raw1394handle_t handle, nodeid_t node,
|
|
196 |
+quadlet_t
|
|
197 |
+avc1394_transaction(raw1394handle_t handle, nodeid_t node,
|
|
198 |
quadlet_t request, int retry)
|
|
199 |
{
|
|
200 |
- quadlet_t response = 0;
|
|
201 |
- struct pollfd raw1394_poll;
|
|
202 |
- raw1394_poll.fd = raw1394_get_fd(handle);
|
|
203 |
- raw1394_poll.events = POLLIN;
|
|
204 |
- struct fcp_response fr;
|
|
205 |
-
|
|
206 |
- do {
|
|
207 |
- response = 0;
|
|
208 |
- fr.length = 0;
|
|
209 |
-
|
|
210 |
- init_avc_response_handler(handle, &fr);
|
|
211 |
- if (avc1394_send_command(handle, node, request) < 0) {
|
|
212 |
- struct timespec ts = {0, AVC1394_SLEEP};
|
|
213 |
- fprintf(stderr,"send oops\n");
|
|
214 |
- nanosleep(&ts, NULL);
|
|
215 |
- continue;
|
|
216 |
- }
|
|
217 |
-
|
|
218 |
- // Only poll if the receive handler hasn't been called yet.
|
|
219 |
- // This can occur while waiting for command acknowledgement inside of
|
|
220 |
- // raw1394_write.
|
|
221 |
- if (fr.length==0) {
|
|
222 |
- if ( poll( &raw1394_poll, 1, AVC1394_POLL_TIMEOUT) > 0 ) {
|
|
223 |
- if (raw1394_poll.revents & POLLIN) {
|
|
224 |
- raw1394_loop_iterate(handle);
|
|
225 |
- response = ntohl(fr.data[0]);
|
|
226 |
- }
|
|
227 |
- }
|
|
228 |
- } else {
|
|
229 |
- response = ntohl(fr.data[0]);
|
|
230 |
- }
|
|
231 |
- if (response != 0) {
|
|
232 |
- while (AVC1394_MASK_RESPONSE(response) == AVC1394_RESPONSE_INTERIM) {
|
|
233 |
-#ifdef DEBUG
|
|
234 |
- fprintf(stderr,"INTERIM\n");
|
|
235 |
-#endif
|
|
236 |
- response = 0;
|
|
237 |
- fr.length = 0;
|
|
238 |
-
|
|
239 |
- if ( poll( &raw1394_poll, 1, AVC1394_POLL_TIMEOUT) > 0 ) {
|
|
240 |
- if (raw1394_poll.revents & POLLIN) {
|
|
241 |
- raw1394_loop_iterate(handle);
|
|
242 |
- response = ntohl(fr.data[0]);
|
|
243 |
- }
|
|
244 |
- }
|
|
245 |
- }
|
|
246 |
- }
|
|
247 |
- stop_avc_response_handler(handle);
|
|
248 |
-
|
|
249 |
-#ifdef DEBUG
|
|
250 |
- if (response != 0)
|
|
251 |
- fprintf(stderr, "avc1394_transaction: Got AVC response 0x%0x (%s)\n", response, decode_response(response));
|
|
252 |
- else
|
|
253 |
- fprintf(stderr, "avc1394_transaction: no response\n");
|
|
254 |
-#endif
|
|
255 |
+ int fd;
|
|
256 |
+ iec61883_arq_t arq;
|
|
257 |
+ ssize_t ssz;
|
|
258 |
+
|
|
259 |
+ fd = solaris_get_fd(handle, node, 1);
|
|
260 |
+ if (fd < 0)
|
|
261 |
+ return -1;
|
|
262 |
+
|
|
263 |
+ if (avc1394_send_command(handle, node, request) != 0)
|
|
264 |
+ return -1;
|
|
265 |
+
|
|
266 |
+again:
|
|
267 |
+ ssz = read(fd, &arq, sizeof (arq));
|
|
268 |
+ if (ssz < 0)
|
|
269 |
+ return -1;
|
|
270 |
+
|
|
271 |
+ if (ssz != sizeof (arq)) {
|
|
272 |
+ (void) fprintf(stderr, "Unexpected read() size on node %d "
|
|
273 |
+ "(%d bytes)\n", node, ssz);
|
|
274 |
+ goto again;
|
|
275 |
+ }
|
|
276 |
+
|
|
277 |
+ switch (arq.arq_type) {
|
|
278 |
+ case IEC61883_ARQ_FCP_RESP:
|
|
279 |
+ break;
|
|
280 |
|
|
281 |
- if (response != 0) {
|
|
282 |
- return response;
|
|
283 |
- }
|
|
284 |
-
|
|
285 |
- } while (--retry >= 0);
|
|
286 |
+ case IEC61883_ARQ_BUS_RESET:
|
|
287 |
+ (void) fprintf(stderr, "Skipping bus reset on node %d.\n",
|
|
288 |
+ node);
|
|
289 |
+ goto again;
|
|
290 |
+
|
|
291 |
+ default:
|
|
292 |
+ (void) fprintf(stderr, "Skipping packet with unexpected "
|
|
293 |
+ "response type %d on node %d.\n", arq.arq_type, node);
|
|
294 |
+ goto again;
|
|
295 |
+ }
|
|
296 |
+
|
|
297 |
+ if (arq.arq_len != IEEE1394_QUADLET) {
|
|
298 |
+ (void) fprintf(stderr, "Skipping packet with unexpected length "
|
|
299 |
+ "%d on node %d.\n", arq.arq_len, node);
|
|
300 |
+ goto again;
|
|
301 |
+ }
|
|
302 |
|
|
303 |
- stop_avc_response_handler(handle);
|
|
304 |
- return (response == 0 ? -1 : response);
|
|
305 |
+ return (ntohl(arq.arq_data.quadlet));
|
|
306 |
}
|
|
307 |
|
|
308 |
/*
|
|
309 |
@@ -171,100 +258,113 @@
|
|
310 |
* RETURNS: the AV/C response if everything went well, NULL in case of an
|
|
311 |
* error.
|
|
312 |
*/
|
|
313 |
-quadlet_t *avc1394_transaction_block2(raw1394handle_t handle, nodeid_t node,
|
|
314 |
+quadlet_t*
|
|
315 |
+avc1394_transaction_block2(raw1394handle_t handle, nodeid_t node,
|
|
316 |
quadlet_t *request, int len, unsigned int *response_len, int retry)
|
|
317 |
{
|
|
318 |
- quadlet_t *response;
|
|
319 |
- struct pollfd raw1394_poll;
|
|
320 |
- raw1394_poll.fd = raw1394_get_fd(handle);
|
|
321 |
- raw1394_poll.events = POLLIN;
|
|
322 |
- struct fcp_response *fr = NULL;
|
|
323 |
+ int fd;
|
|
324 |
+ iec61883_arq_t *arqp;
|
|
325 |
+ size_t asz;
|
|
326 |
+ quadlet_t *rbuf;
|
|
327 |
+ ssize_t ssz;
|
|
328 |
|
|
329 |
*response_len = 0;
|
|
330 |
- fr = calloc(1, sizeof(struct fcp_response));
|
|
331 |
- if (fr == NULL)
|
|
332 |
+ fd = solaris_get_fd(handle, node, 1);
|
|
333 |
+ if (fd < 0)
|
|
334 |
return NULL;
|
|
335 |
|
|
336 |
- do {
|
|
337 |
- response = NULL;
|
|
338 |
- fr->length = 0;
|
|
339 |
- *response_len = 0;
|
|
340 |
-
|
|
341 |
- init_avc_response_handler(handle, fr);
|
|
342 |
- if (avc1394_send_command_block(handle, node, request, len) < 0) {
|
|
343 |
- struct timespec ts = {0, AVC1394_SLEEP};
|
|
344 |
- fprintf(stderr,"send oops\n");
|
|
345 |
- nanosleep(&ts, NULL);
|
|
346 |
- continue;
|
|
347 |
- }
|
|
348 |
-
|
|
349 |
- // Only poll if the receive handler hasn't been called yet.
|
|
350 |
- // This can occur while waiting for command acknowledgement inside of
|
|
351 |
- // raw1394_write.
|
|
352 |
- if (fr->length==0) {
|
|
353 |
- if ( poll( &raw1394_poll, 1, AVC1394_POLL_TIMEOUT) > 0 ) {
|
|
354 |
- if (raw1394_poll.revents & POLLIN) {
|
|
355 |
- raw1394_loop_iterate(handle);
|
|
356 |
- response = fr->data;
|
|
357 |
- ntohl_block(response, fr->length);
|
|
358 |
- *response_len = fr->length;
|
|
359 |
- }
|
|
360 |
- }
|
|
361 |
- } else {
|
|
362 |
- response = fr->data;
|
|
363 |
- ntohl_block(response, fr->length);
|
|
364 |
- *response_len = fr->length;
|
|
365 |
- }
|
|
366 |
- if (response != NULL) {
|
|
367 |
- while (AVC1394_MASK_RESPONSE(response[0]) == AVC1394_RESPONSE_INTERIM) {
|
|
368 |
-#ifdef DEBUG
|
|
369 |
- fprintf(stderr,"INTERIM\n");
|
|
370 |
-#endif
|
|
371 |
- response = NULL;
|
|
372 |
- fr->length = 0;
|
|
373 |
- *response_len = 0;
|
|
374 |
-
|
|
375 |
- if ( poll( &raw1394_poll, 1, AVC1394_POLL_TIMEOUT) > 0 ) {
|
|
376 |
- if (raw1394_poll.revents & POLLIN) {
|
|
377 |
- raw1394_loop_iterate(handle);
|
|
378 |
- response = fr->data;
|
|
379 |
- ntohl_block(response, fr->length);
|
|
380 |
- *response_len = fr->length;
|
|
381 |
- }
|
|
382 |
- }
|
|
383 |
- }
|
|
384 |
- }
|
|
385 |
- stop_avc_response_handler(handle);
|
|
386 |
-
|
|
387 |
-#ifdef DEBUG
|
|
388 |
- if (response != NULL) {
|
|
389 |
- int i;
|
|
390 |
- fprintf(stderr, "avc1394_transaction_block received response (retry %d): ",
|
|
391 |
- retry);
|
|
392 |
- for (i=0; i<len; i++) fprintf(stderr, " 0x%08X", response[i]);
|
|
393 |
- fprintf(stderr, " (%s)\n", decode_response(response[0]));
|
|
394 |
- } else {
|
|
395 |
- fprintf(stderr, "avc1394_transaction_block: no response\n");
|
|
396 |
+ asz = sizeof (*arqp) - sizeof (arqp->arq_data) + len * 4;
|
|
397 |
+ arqp = malloc(asz);
|
|
398 |
+ if (arqp == NULL)
|
|
399 |
+ return NULL;
|
|
400 |
+
|
|
401 |
+ rbuf = malloc(len * 4);
|
|
402 |
+ if (rbuf == NULL) {
|
|
403 |
+ free(arqp);
|
|
404 |
+ return NULL;
|
|
405 |
}
|
|
406 |
-#endif
|
|
407 |
|
|
408 |
- if (response != NULL) {
|
|
409 |
- return response;
|
|
410 |
- }
|
|
411 |
- } while (--retry >= 0);
|
|
412 |
+ if (avc1394_send_command_block(handle, node, request, len) < 0)
|
|
413 |
+ goto err;
|
|
414 |
|
|
415 |
- stop_avc_response_handler(handle);
|
|
416 |
+again:
|
|
417 |
+ ssz = read(fd, arqp, sizeof (iec61883_arq_t));
|
|
418 |
+ if (ssz < 0)
|
|
419 |
+ goto err;
|
|
420 |
+
|
|
421 |
+ if (ssz != sizeof (iec61883_arq_t)) {
|
|
422 |
+ (void) fprintf(stderr, "Unexpected read() size on node %d "
|
|
423 |
+ "(%d bytes)\n", node, ssz);
|
|
424 |
+ goto again;
|
|
425 |
+ }
|
|
426 |
+
|
|
427 |
+ switch (arqp->arq_type) {
|
|
428 |
+ case IEC61883_ARQ_FCP_RESP:
|
|
429 |
+ *response_len = (unsigned int) arqp->arq_len;
|
|
430 |
+ break;
|
|
431 |
+ case IEC61883_ARQ_BUS_RESET:
|
|
432 |
+ (void) fprintf(stderr, "Skipping bus reset on node %d.\n",
|
|
433 |
+ node);
|
|
434 |
+ goto again;
|
|
435 |
+
|
|
436 |
+ default:
|
|
437 |
+ (void) fprintf(stderr, "Skipping packet with unexpected "
|
|
438 |
+ "response type %d on node %d.\n", arqp->arq_type, node);
|
|
439 |
+ goto again;
|
|
440 |
+ }
|
|
441 |
+
|
|
442 |
+ if (arqp->arq_len != len * 4) {
|
|
443 |
+ (void) fprintf(stderr, "Skipping packet with unexpected length "
|
|
444 |
+ "%d != %d on node %d.\n", arqp->arq_len, len * 4, node);
|
|
445 |
+ goto again;
|
|
446 |
+ }
|
|
447 |
+
|
|
448 |
+ ssz = read(fd, arqp, asz);
|
|
449 |
+ if (ssz < 0)
|
|
450 |
+ goto err;
|
|
451 |
+
|
|
452 |
+ if (ssz != asz) {
|
|
453 |
+ (void) fprintf(stderr, "Unexpected read() size on node %d "
|
|
454 |
+ "(%d bytes)\n", node, ssz);
|
|
455 |
+ goto err;
|
|
456 |
+ }
|
|
457 |
+
|
|
458 |
+ switch (arqp->arq_type) {
|
|
459 |
+ case IEC61883_ARQ_FCP_RESP:
|
|
460 |
+ *response_len = (unsigned int) arqp->arq_len;
|
|
461 |
+ break;
|
|
462 |
+ case IEC61883_ARQ_BUS_RESET:
|
|
463 |
+ (void) fprintf(stderr, "Skipping bus reset on node %d.\n",
|
|
464 |
+ node);
|
|
465 |
+ goto err;
|
|
466 |
+
|
|
467 |
+ default:
|
|
468 |
+ (void) fprintf(stderr, "Skipping packet with unexpected "
|
|
469 |
+ "response type %d on node %d.\n", arqp->arq_type, node);
|
|
470 |
+ goto err;
|
|
471 |
+ }
|
|
472 |
+ for (int i = 0; i < len; ++i)
|
|
473 |
+ rbuf[i] = ntohl(((quadlet_t *)&arqp->arq_data)[i]);
|
|
474 |
+
|
|
475 |
+ free(arqp);
|
|
476 |
+ return rbuf;
|
|
477 |
+
|
|
478 |
+err:
|
|
479 |
+ free(arqp);
|
|
480 |
+ free(rbuf);
|
|
481 |
return NULL;
|
|
482 |
}
|
|
483 |
|
|
484 |
/*
|
|
485 |
* kept for backwards compatibility
|
|
486 |
*/
|
|
487 |
-quadlet_t *avc1394_transaction_block(raw1394handle_t handle, nodeid_t node,
|
|
488 |
+quadlet_t*
|
|
489 |
+avc1394_transaction_block(raw1394handle_t handle, nodeid_t node,
|
|
490 |
quadlet_t *request, int len, int retry)
|
|
491 |
{
|
|
492 |
unsigned int response_len;
|
|
493 |
- return avc1394_transaction_block2(handle, node, request, len, &response_len, retry);
|
|
494 |
+ return avc1394_transaction_block2(handle, node, request, len,
|
|
495 |
+ &response_len, retry);
|
|
496 |
}
|
|
497 |
|
|
498 |
void avc1394_transaction_block_close(raw1394handle_t handle)
|
|
499 |
@@ -381,9 +481,10 @@
|
|
500 |
* Caller must call avc1394_transaction_block_close() when finished with
|
|
501 |
* return value.
|
|
502 |
*/
|
|
503 |
-unsigned char *avc1394_read_descriptor(raw1394handle_t handle, nodeid_t node,
|
|
504 |
- quadlet_t subunit,
|
|
505 |
- unsigned char *descriptor_identifier, int len_descriptor_identifier)
|
|
506 |
+unsigned char*
|
|
507 |
+avc1394_read_descriptor(raw1394handle_t handle, nodeid_t node,
|
|
508 |
+ quadlet_t subunit, unsigned char *descriptor_identifier,
|
|
509 |
+ int len_descriptor_identifier)
|
|
510 |
{
|
|
511 |
quadlet_t request[128];
|
|
512 |
quadlet_t *response;
|
|
513 |
@@ -392,8 +493,7 @@
|
|
514 |
fprintf(stderr, "Unimplemented.\n");
|
|
515 |
|
|
516 |
memset(request, 0, 128*4);
|
|
517 |
- request[0] = AVC1394_CTYPE_CONTROL | subunit | AVC1394_COMMAND_READ_DESCRIPTOR
|
|
518 |
- | *descriptor_identifier;
|
|
519 |
+ request[0] = AVC1394_CTYPE_CONTROL | subunit | AVC1394_COMMAND_READ_DESCRIPTOR | *descriptor_identifier;
|
|
520 |
request[1] = 0xFF000000; /* read entire descriptor */
|
|
521 |
request[2] = 0x00000000; /* beginning from 0x0000 */
|
|
522 |
|
|
523 |
@@ -408,7 +508,8 @@
|
|
524 |
* Get subunit info
|
|
525 |
*/
|
|
526 |
#define EXTENSION_CODE 7
|
|
527 |
-int avc1394_subunit_info(raw1394handle_t handle, nodeid_t node, quadlet_t *table)
|
|
528 |
+int
|
|
529 |
+avc1394_subunit_info(raw1394handle_t handle, nodeid_t node, quadlet_t *table)
|
|
530 |
{
|
|
531 |
quadlet_t request[2];
|
|
532 |
quadlet_t *response;
|
|
533 |
@@ -429,11 +530,10 @@
|
|
534 |
}
|
|
535 |
|
|
536 |
#ifdef DEBUG
|
|
537 |
- {
|
|
538 |
- fprintf(stderr, "avc_subunit_info:");
|
|
539 |
- for (page=0; page < 8; page++) fprintf(stderr, " 0x%08X", table[page]);
|
|
540 |
- fprintf(stderr, "\n");
|
|
541 |
- }
|
|
542 |
+ (void) fprintf(stderr, "avc_subunit_info:");
|
|
543 |
+ for (page=0; page < 8; page++)
|
|
544 |
+ (void) fprintf(stderr, " 0x%08X", table[page]);
|
|
545 |
+ (void) fprintf(stderr, "\n");
|
|
546 |
#endif
|
|
547 |
|
|
548 |
return 0;
|
|
549 |
@@ -448,6 +548,7 @@
|
|
550 |
|
|
551 |
if ( avc1394_subunit_info( handle, node, table) < 0)
|
|
552 |
return 0;
|
|
553 |
+
|
|
554 |
for (i=0; i<8; i++) {
|
|
555 |
for (j=3; j>=0; j--) {
|
|
556 |
entry = (table[i] >> (j * 8)) & 0xFF;
|
|
557 |
@@ -465,21 +566,21 @@
|
|
558 |
* Caller must call avc1394_transaction_block_close() when finished with
|
|
559 |
* return value.
|
|
560 |
*/
|
|
561 |
-quadlet_t *avc1394_unit_info(raw1394handle_t handle, nodeid_t node)
|
|
562 |
+quadlet_t*
|
|
563 |
+avc1394_unit_info(raw1394handle_t handle, nodeid_t node)
|
|
564 |
{
|
|
565 |
|
|
566 |
quadlet_t request[2];
|
|
567 |
quadlet_t *response;
|
|
568 |
|
|
569 |
- request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT
|
|
570 |
- | AVC1394_SUBUNIT_ID_IGNORE | AVC1394_COMMAND_UNIT_INFO | 0xFF;
|
|
571 |
+ request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE | AVC1394_COMMAND_UNIT_INFO | 0xFF;
|
|
572 |
request[1] = 0xFFFFFFFF;
|
|
573 |
response = avc1394_transaction_block(handle, node, request, 2, AVC1394_RETRY);
|
|
574 |
if (response == NULL)
|
|
575 |
return NULL;
|
|
576 |
|
|
577 |
#ifdef DEBUG
|
|
578 |
- fprintf(stderr, "avc_unit_info: 0x%08X 0x%08X\n",
|
|
579 |
+ (void) fprintf(stderr, "avc_unit_info: 0x%08X 0x%08X\n",
|
|
580 |
response[0], response[1]);
|
|
581 |
#endif
|
|
582 |
return response;
|
|
583 |
@@ -489,7 +590,8 @@
|
|
584 |
|
|
585 |
avc1394_command_handler_t g_command_handler = NULL;
|
|
586 |
|
|
587 |
-int target_fcp_handler( raw1394handle_t handle, nodeid_t nodeid, int response,
|
|
588 |
+int
|
|
589 |
+target_fcp_handler( raw1394handle_t handle, nodeid_t nodeid, int response,
|
|
590 |
size_t length, unsigned char *data )
|
|
591 |
{
|
|
592 |
int result;
|
|
593 |
@@ -500,24 +602,19 @@
|
|
594 |
memset(&cmd_resp, 0, sizeof(cmd_resp));
|
|
595 |
memcpy(r, data, length);
|
|
596 |
|
|
597 |
- if ( response != 0 )
|
|
598 |
- {
|
|
599 |
+ if (response != 0) {
|
|
600 |
return 0;
|
|
601 |
- }
|
|
602 |
- else
|
|
603 |
- {
|
|
604 |
+ } else {
|
|
605 |
#ifdef DEBUG
|
|
606 |
- {
|
|
607 |
int q, z;
|
|
608 |
z = (length % 4) ? length + (4 - (length % 4)) : length;
|
|
609 |
printf("----> ");
|
|
610 |
for (q = 0; q < z / 4; q++)
|
|
611 |
printf("%08x ", r[q]);
|
|
612 |
- printf("(length %d)\n", length);
|
|
613 |
- printf("----> type=0x%02x subunit_type=0x%x subunit_id=0x%x opcode=0x%x operand0=0x%x\n",
|
|
614 |
+ (void) fprintf(stderr, "(length %d)\n", length);
|
|
615 |
+ (void) fprintf(stderr, "----> type=0x%02x subunit_type=0x%x subunit_id=0x%x opcode=0x%x operand0=0x%x\n",
|
|
616 |
cmd_resp.status, cmd_resp.subunit_type,
|
|
617 |
cmd_resp.subunit_id, cmd_resp.opcode, cmd_resp.operand[0]);
|
|
618 |
- }
|
|
619 |
#endif
|
|
620 |
result = g_command_handler( &cmd_resp );
|
|
621 |
|
|
622 |
@@ -525,26 +622,27 @@
|
|
623 |
cmd_resp.status = AVC1394_RESP_NOT_IMPLEMENTED;
|
|
624 |
|
|
625 |
#ifdef DEBUG
|
|
626 |
- {
|
|
627 |
int q, z;
|
|
628 |
z = (length % 4) ? length + (4 - (length % 4)) : length;
|
|
629 |
printf("<---- ");
|
|
630 |
for (q = 0; q < z / 4; q++)
|
|
631 |
printf("%08x ", r[q]);
|
|
632 |
- printf("(length %d)\n", length);
|
|
633 |
- printf("<---- type=0x%02x subunit_type=0x%x subunit_id=0x%x opcode=0x%x operand0=0x%x\n",
|
|
634 |
+ (void) fprintf(stderr, "(length %d)\n", length);
|
|
635 |
+ (void) fprintf(stderr, "<---- type=0x%02x subunit_type=0x%x subunit_id=0x%x opcode=0x%x operand0=0x%x\n",
|
|
636 |
cmd_resp.status, cmd_resp.subunit_type,
|
|
637 |
cmd_resp.subunit_id, cmd_resp.opcode, cmd_resp.operand[0]);
|
|
638 |
- }
|
|
639 |
#endif
|
|
640 |
|
|
641 |
- return cooked1394_write(handle, 0xffc0 | nodeid, FCP_RESPONSE_ADDR, length, r);
|
|
642 |
+ result = avc1394_send_command_block(handle, (0xffc0 | nodeid), r,
|
|
643 |
+ length);
|
|
644 |
+ return result;
|
|
645 |
}
|
|
646 |
}
|
|
647 |
|
|
648 |
|
|
649 |
int
|
|
650 |
-avc1394_init_target( raw1394handle_t handle, avc1394_command_handler_t cmd_handler)
|
|
651 |
+avc1394_init_target( raw1394handle_t handle,
|
|
652 |
+ avc1394_command_handler_t cmd_handler)
|
|
653 |
{
|
|
654 |
if (cmd_handler == NULL)
|
|
655 |
return -1;
|
|
656 |
@@ -560,3 +658,4 @@
|
|
657 |
{
|
|
658 |
return raw1394_stop_fcp_listen(handle);
|
|
659 |
}
|
|
660 |
+
|
|
661 |
diff -ur libavc1394-0.5.3.orig/libavc1394/avc1394_vcr.c libavc1394-0.5.3/libavc1394/avc1394_vcr.c
|
|
662 |
--- libavc1394-0.5.3.orig/libavc1394/avc1394_vcr.c 2006-04-13 23:16:41.000000000 +0700
|
|
663 |
+++ libavc1394-0.5.3/libavc1394/avc1394_vcr.c 2007-09-30 21:15:37.358893716 +0700
|
|
664 |
@@ -22,6 +22,8 @@
|
|
665 |
#include <unistd.h>
|
|
666 |
#include <stdio.h>
|
|
667 |
#include <stdlib.h>
|
|
668 |
+#include <string.h>
|
|
669 |
+#include <errno.h>
|
|
670 |
#include "avc1394_vcr.h"
|
|
671 |
#include "avc1394.h"
|
|
672 |
|
|
673 |
@@ -35,196 +37,272 @@
|
|
674 |
#define CTLUNIT AVC1394_CTYPE_CONTROL | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE
|
|
675 |
#define STATUNIT AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE
|
|
676 |
|
|
677 |
-int avc1394_vcr_is_playing(raw1394handle_t handle, nodeid_t node)
|
|
678 |
+static void
|
|
679 |
+_send_command_failed(const char *file, int line, int err, const char *func)
|
|
680 |
{
|
|
681 |
- quadlet_t response = avc1394_transaction(handle, node, STATVCR0
|
|
682 |
- | AVC1394_VCR_COMMAND_TRANSPORT_STATE | AVC1394_VCR_OPERAND_TRANSPORT_STATE,
|
|
683 |
- AVC1394_RETRY);
|
|
684 |
- if (AVC1394_MASK_OPCODE(response)
|
|
685 |
- == AVC1394_VCR_RESPONSE_TRANSPORT_STATE_PLAY)
|
|
686 |
+ (void) fprintf(stderr, "%s:%d: avc1394_send_command() failed with "
|
|
687 |
+ "errno %d (%s) in %s\n", file, line, err, strerror(err), func);
|
|
688 |
+}
|
|
689 |
+
|
|
690 |
+#define send_command_failed(err, func) \
|
|
691 |
+ _send_command_failed(__FILE__, __LINE__, err, func)
|
|
692 |
+
|
|
693 |
+
|
|
694 |
+int
|
|
695 |
+avc1394_vcr_is_playing(raw1394handle_t handle, nodeid_t node)
|
|
696 |
+{
|
|
697 |
+ quadlet_t response;
|
|
698 |
+
|
|
699 |
+ response = avc1394_transaction(handle, node, STATVCR0 |
|
|
700 |
+ AVC1394_VCR_COMMAND_TRANSPORT_STATE |
|
|
701 |
+ AVC1394_VCR_OPERAND_TRANSPORT_STATE, AVC1394_RETRY);
|
|
702 |
+
|
|
703 |
+ if (AVC1394_MASK_OPCODE(response) ==
|
|
704 |
+ AVC1394_VCR_RESPONSE_TRANSPORT_STATE_PLAY)
|
|
705 |
return AVC1394_GET_OPERAND0(response);
|
|
706 |
- else
|
|
707 |
+
|
|
708 |
return 0;
|
|
709 |
}
|
|
710 |
|
|
711 |
|
|
712 |
-int avc1394_vcr_is_recording(raw1394handle_t handle, nodeid_t node)
|
|
713 |
+int
|
|
714 |
+avc1394_vcr_is_recording(raw1394handle_t handle, nodeid_t node)
|
|
715 |
{
|
|
716 |
- quadlet_t response = avc1394_transaction(handle, node, STATVCR0
|
|
717 |
- | AVC1394_VCR_COMMAND_TRANSPORT_STATE | AVC1394_VCR_OPERAND_TRANSPORT_STATE,
|
|
718 |
- AVC1394_RETRY);
|
|
719 |
- if (AVC1394_MASK_OPCODE(response)
|
|
720 |
- == AVC1394_VCR_RESPONSE_TRANSPORT_STATE_RECORD)
|
|
721 |
+ quadlet_t response;
|
|
722 |
+
|
|
723 |
+ response = avc1394_transaction(handle, node, STATVCR0 |
|
|
724 |
+ AVC1394_VCR_COMMAND_TRANSPORT_STATE |
|
|
725 |
+ AVC1394_VCR_OPERAND_TRANSPORT_STATE, AVC1394_RETRY);
|
|
726 |
+
|
|
727 |
+ if (AVC1394_MASK_OPCODE(response) ==
|
|
728 |
+ AVC1394_VCR_RESPONSE_TRANSPORT_STATE_RECORD)
|
|
729 |
return AVC1394_GET_OPERAND0(response);
|
|
730 |
- else
|
|
731 |
+
|
|
732 |
return 0;
|
|
733 |
}
|
|
734 |
|
|
735 |
|
|
736 |
-void avc1394_vcr_play(raw1394handle_t handle, nodeid_t node)
|
|
737 |
+void
|
|
738 |
+avc1394_vcr_play(raw1394handle_t handle, nodeid_t node)
|
|
739 |
{
|
|
740 |
- if (avc1394_vcr_is_playing(handle, node) == AVC1394_VCR_OPERAND_PLAY_FORWARD) {
|
|
741 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
742 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_SLOWEST_FORWARD);
|
|
743 |
- } else {
|
|
744 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
745 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_FORWARD);
|
|
746 |
- }
|
|
747 |
+ int op;
|
|
748 |
+
|
|
749 |
+ if (avc1394_vcr_is_playing(handle, node) ==
|
|
750 |
+ AVC1394_VCR_OPERAND_PLAY_FORWARD)
|
|
751 |
+ op = AVC1394_VCR_OPERAND_PLAY_SLOWEST_FORWARD;
|
|
752 |
+ else
|
|
753 |
+ op = AVC1394_VCR_OPERAND_PLAY_FORWARD;
|
|
754 |
+
|
|
755 |
+ if (avc1394_send_command(handle, node,
|
|
756 |
+ CTLVCR0 | AVC1394_VCR_COMMAND_PLAY | op) < 0)
|
|
757 |
+ send_command_failed(errno, "avc1394_vcr_play");
|
|
758 |
}
|
|
759 |
|
|
760 |
|
|
761 |
-void avc1394_vcr_reverse(raw1394handle_t handle, nodeid_t node)
|
|
762 |
+void
|
|
763 |
+avc1394_vcr_reverse(raw1394handle_t handle, nodeid_t node)
|
|
764 |
{
|
|
765 |
- if (avc1394_vcr_is_playing(handle, node) == AVC1394_VCR_OPERAND_PLAY_REVERSE) {
|
|
766 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
767 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_SLOWEST_REVERSE);
|
|
768 |
- } else {
|
|
769 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
770 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_REVERSE);
|
|
771 |
- }
|
|
772 |
+ int op;
|
|
773 |
+
|
|
774 |
+ if (avc1394_vcr_is_playing(handle, node) ==
|
|
775 |
+ AVC1394_VCR_OPERAND_PLAY_REVERSE)
|
|
776 |
+ op = AVC1394_VCR_OPERAND_PLAY_SLOWEST_REVERSE;
|
|
777 |
+ else
|
|
778 |
+ op = AVC1394_VCR_OPERAND_PLAY_REVERSE;
|
|
779 |
+ if (avc1394_send_command(handle, node,
|
|
780 |
+ CTLVCR0 | AVC1394_VCR_COMMAND_PLAY | op) < 0)
|
|
781 |
+ send_command_failed(errno, "avc1394_vcr_reverse");
|
|
782 |
}
|
|
783 |
|
|
784 |
|
|
785 |
-void avc1394_vcr_trick_play(raw1394handle_t handle, nodeid_t node, int speed)
|
|
786 |
+void
|
|
787 |
+avc1394_vcr_trick_play(raw1394handle_t handle, nodeid_t node, int speed)
|
|
788 |
{
|
|
789 |
- if (!avc1394_vcr_is_recording(handle, node)) {
|
|
790 |
+ int op;
|
|
791 |
+
|
|
792 |
+ if (avc1394_vcr_is_recording(handle, node))
|
|
793 |
+ return;
|
|
794 |
+
|
|
795 |
if (speed == 0) {
|
|
796 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
797 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_FORWARD);
|
|
798 |
+ op = AVC1394_VCR_OPERAND_PLAY_FORWARD;
|
|
799 |
} else if (speed > 0) {
|
|
800 |
- if (speed > 14) speed = 14;
|
|
801 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
802 |
- | AVC1394_VCR_COMMAND_PLAY | (AVC1394_VCR_OPERAND_PLAY_NEXT_FRAME + speed));
|
|
803 |
- } else {
|
|
804 |
- if (speed < -14) speed = -14;
|
|
805 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
806 |
- | AVC1394_VCR_COMMAND_PLAY | (AVC1394_VCR_OPERAND_PLAY_PREVIOUS_FRAME - speed));
|
|
807 |
- }
|
|
808 |
+ if (speed > 14)
|
|
809 |
+ speed = 14;
|
|
810 |
+ op = AVC1394_VCR_OPERAND_PLAY_NEXT_FRAME + speed;
|
|
811 |
+ } else {
|
|
812 |
+ if (speed < -14)
|
|
813 |
+ speed = -14;
|
|
814 |
+ op = AVC1394_VCR_OPERAND_PLAY_PREVIOUS_FRAME - speed;
|
|
815 |
}
|
|
816 |
+
|
|
817 |
+ if (avc1394_send_command(handle, node,
|
|
818 |
+ CTLVCR0 | AVC1394_VCR_COMMAND_PLAY | op) < 0)
|
|
819 |
+ send_command_failed(errno, "avc1394_vcr_trick_play");
|
|
820 |
}
|
|
821 |
|
|
822 |
|
|
823 |
-void avc1394_vcr_stop(raw1394handle_t handle, nodeid_t node)
|
|
824 |
+void
|
|
825 |
+avc1394_vcr_stop(raw1394handle_t handle, nodeid_t node)
|
|
826 |
{
|
|
827 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
828 |
- | AVC1394_VCR_COMMAND_WIND | AVC1394_VCR_OPERAND_WIND_STOP);
|
|
829 |
+ if (avc1394_send_command(handle, node, CTLVCR0
|
|
830 |
+ | AVC1394_VCR_COMMAND_WIND | AVC1394_VCR_OPERAND_WIND_STOP) != 0)
|
|
831 |
+ send_command_failed(errno, "avc1394_vcr_stop");
|
|
832 |
}
|
|
833 |
|
|
834 |
|
|
835 |
-void avc1394_vcr_rewind(raw1394handle_t handle, nodeid_t node)
|
|
836 |
+void
|
|
837 |
+avc1394_vcr_rewind(raw1394handle_t handle, nodeid_t node)
|
|
838 |
{
|
|
839 |
- if (avc1394_vcr_is_playing(handle, node)) {
|
|
840 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
841 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_FASTEST_REVERSE);
|
|
842 |
- } else {
|
|
843 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
844 |
- | AVC1394_VCR_COMMAND_WIND | AVC1394_VCR_OPERAND_WIND_REWIND);
|
|
845 |
- }
|
|
846 |
+ int op;
|
|
847 |
+
|
|
848 |
+ op = avc1394_vcr_is_playing(handle, node) ?
|
|
849 |
+ AVC1394_VCR_OPERAND_PLAY_FASTEST_REVERSE :
|
|
850 |
+ AVC1394_VCR_OPERAND_WIND_REWIND;
|
|
851 |
+
|
|
852 |
+ if (avc1394_send_command(handle, node,
|
|
853 |
+ CTLVCR0 | AVC1394_VCR_COMMAND_PLAY | op) != 0)
|
|
854 |
+ send_command_failed(errno, "avc1394_vcr_rewind");
|
|
855 |
}
|
|
856 |
|
|
857 |
|
|
858 |
-void avc1394_vcr_pause(raw1394handle_t handle, nodeid_t node)
|
|
859 |
+void
|
|
860 |
+avc1394_vcr_pause(raw1394handle_t handle, nodeid_t node)
|
|
861 |
{
|
|
862 |
int mode;
|
|
863 |
+ int cmd;
|
|
864 |
|
|
865 |
- if ((mode = avc1394_vcr_is_recording(handle, node))) {
|
|
866 |
- if (mode == AVC1394_VCR_OPERAND_RECORD_PAUSE) {
|
|
867 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
868 |
- | AVC1394_VCR_COMMAND_RECORD | AVC1394_VCR_OPERAND_RECORD_RECORD);
|
|
869 |
- } else {
|
|
870 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
871 |
- | AVC1394_VCR_COMMAND_RECORD | AVC1394_VCR_OPERAND_RECORD_PAUSE);
|
|
872 |
- }
|
|
873 |
- } else {
|
|
874 |
- if (avc1394_vcr_is_playing(handle, node)==AVC1394_VCR_OPERAND_PLAY_FORWARD_PAUSE) {
|
|
875 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
876 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_FORWARD);
|
|
877 |
- } else {
|
|
878 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
879 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_FORWARD_PAUSE);
|
|
880 |
+ mode = avc1394_vcr_is_recording(handle, node);
|
|
881 |
+
|
|
882 |
+ switch(mode) {
|
|
883 |
+ case AVC1394_VCR_OPERAND_RECORD_PAUSE:
|
|
884 |
+ cmd = AVC1394_VCR_COMMAND_RECORD |
|
|
885 |
+ AVC1394_VCR_OPERAND_RECORD_RECORD;
|
|
886 |
+ break;
|
|
887 |
+ default:
|
|
888 |
+ cmd = AVC1394_VCR_COMMAND_RECORD |
|
|
889 |
+ AVC1394_VCR_OPERAND_RECORD_PAUSE;
|
|
890 |
+ break;
|
|
891 |
+
|
|
892 |
+ case 0: {
|
|
893 |
+ cmd = AVC1394_VCR_COMMAND_PLAY;
|
|
894 |
+ if (avc1394_vcr_is_playing(handle, node) ==
|
|
895 |
+ AVC1394_VCR_OPERAND_PLAY_FORWARD_PAUSE)
|
|
896 |
+ cmd |= AVC1394_VCR_OPERAND_PLAY_FORWARD;
|
|
897 |
+ else
|
|
898 |
+ cmd |= AVC1394_VCR_OPERAND_PLAY_FORWARD_PAUSE;
|
|
899 |
}
|
|
900 |
}
|
|
901 |
-
|
|
902 |
+ if (avc1394_send_command(handle, node, CTLVCR0 | cmd) < 0)
|
|
903 |
+ send_command_failed(errno, "avc1394_vcr_pause");
|
|
904 |
}
|
|
905 |
|
|
906 |
|
|
907 |
-void avc1394_vcr_forward(raw1394handle_t handle, nodeid_t node)
|
|
908 |
+void
|
|
909 |
+avc1394_vcr_forward(raw1394handle_t handle, nodeid_t node)
|
|
910 |
{
|
|
911 |
- if (avc1394_vcr_is_playing(handle, node)) {
|
|
912 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
913 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_FASTEST_FORWARD);
|
|
914 |
- } else {
|
|
915 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
916 |
- | AVC1394_VCR_COMMAND_WIND | AVC1394_VCR_OPERAND_WIND_FAST_FORWARD);
|
|
917 |
+ int cmd;
|
|
918 |
+ if (avc1394_vcr_is_playing(handle, node))
|
|
919 |
+ cmd = AVC1394_VCR_COMMAND_PLAY|AVC1394_VCR_OPERAND_PLAY_FASTEST_FORWARD;
|
|
920 |
+ else
|
|
921 |
+ cmd = AVC1394_VCR_COMMAND_WIND|AVC1394_VCR_OPERAND_WIND_FAST_FORWARD;
|
|
922 |
|
|
923 |
- }
|
|
924 |
+ if (avc1394_send_command(handle, node, CTLVCR0 | cmd) < 0)
|
|
925 |
+ send_command_failed(errno, "avc1394_vcr_forward");
|
|
926 |
}
|
|
927 |
|
|
928 |
|
|
929 |
-void avc1394_vcr_next(raw1394handle_t handle, nodeid_t node)
|
|
930 |
+void
|
|
931 |
+avc1394_vcr_next(raw1394handle_t handle, nodeid_t node)
|
|
932 |
{
|
|
933 |
- if (avc1394_vcr_is_playing(handle, node)) {
|
|
934 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
935 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_NEXT_FRAME);
|
|
936 |
- }
|
|
937 |
+ if (!avc1394_vcr_is_playing(handle, node))
|
|
938 |
+ return;
|
|
939 |
+
|
|
940 |
+ if (avc1394_send_command(handle, node, CTLVCR0
|
|
941 |
+ | AVC1394_VCR_COMMAND_PLAY
|
|
942 |
+ | AVC1394_VCR_OPERAND_PLAY_NEXT_FRAME) != 0)
|
|
943 |
+ send_command_failed(errno, "avc1394_vcr_next");
|
|
944 |
}
|
|
945 |
|
|
946 |
-void avc1394_vcr_next_index(raw1394handle_t handle, nodeid_t node)
|
|
947 |
+void
|
|
948 |
+avc1394_vcr_next_index(raw1394handle_t handle, nodeid_t node)
|
|
949 |
{
|
|
950 |
quadlet_t request[2];
|
|
951 |
- if (avc1394_vcr_is_playing(handle, node)) {
|
|
952 |
+
|
|
953 |
+ if (!avc1394_vcr_is_playing(handle, node))
|
|
954 |
+ return ;
|
|
955 |
+
|
|
956 |
request[0] = CTLVCR0 | AVC1394_VCR_COMMAND_FORWARD |
|
|
957 |
AVC1394_VCR_MEASUREMENT_INDEX;
|
|
958 |
request[1] = 0x01FFFFFF;
|
|
959 |
- avc1394_send_command_block(handle, node, request, 2);
|
|
960 |
- }
|
|
961 |
+
|
|
962 |
+ if (avc1394_send_command_block(handle, node, request, 2) != 0)
|
|
963 |
+ (void) fprintf(stderr, "avc1394_send_command_block() failed with "
|
|
964 |
+ "errno %d (%s) in avc1394_vcr_next_index()\n", errno,
|
|
965 |
+ strerror(errno));
|
|
966 |
}
|
|
967 |
|
|
968 |
-void avc1394_vcr_previous(raw1394handle_t handle, nodeid_t node)
|
|
969 |
+void
|
|
970 |
+avc1394_vcr_previous(raw1394handle_t handle, nodeid_t node)
|
|
971 |
{
|
|
972 |
- if (avc1394_vcr_is_playing(handle, node)) {
|
|
973 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
974 |
- | AVC1394_VCR_COMMAND_PLAY | AVC1394_VCR_OPERAND_PLAY_PREVIOUS_FRAME);
|
|
975 |
- }
|
|
976 |
+ if (!avc1394_vcr_is_playing(handle, node))
|
|
977 |
+ return;
|
|
978 |
+
|
|
979 |
+ if (avc1394_send_command(handle, node, CTLVCR0
|
|
980 |
+ | AVC1394_VCR_COMMAND_PLAY
|
|
981 |
+ | AVC1394_VCR_OPERAND_PLAY_PREVIOUS_FRAME) != 0)
|
|
982 |
+ send_command_failed(errno, "avc1394_vcr_previous");
|
|
983 |
+
|
|
984 |
}
|
|
985 |
|
|
986 |
-void avc1394_vcr_previous_index(raw1394handle_t handle, nodeid_t node)
|
|
987 |
+void
|
|
988 |
+avc1394_vcr_previous_index(raw1394handle_t handle, nodeid_t node)
|
|
989 |
{
|
|
990 |
quadlet_t request[2];
|
|
991 |
- if (avc1394_vcr_is_playing(handle, node)) {
|
|
992 |
+
|
|
993 |
+ if (!avc1394_vcr_is_playing(handle, node))
|
|
994 |
+ return;
|
|
995 |
+
|
|
996 |
request[0] = CTLVCR0 | AVC1394_VCR_COMMAND_BACKWARD |
|
|
997 |
AVC1394_VCR_MEASUREMENT_INDEX;
|
|
998 |
request[1] = 0x01FFFFFF;
|
|
999 |
- avc1394_send_command_block(handle, node, request, 2);
|
|
1000 |
- }
|
|
1001 |
+
|
|
1002 |
+ if (avc1394_send_command_block(handle, node, request, 2) != 0)
|
|
1003 |
+ (void) fprintf(stderr, "avc1394_send_command_block() failed with "
|
|
1004 |
+ "errno %d (%s) in avc1394_vcr_previous_index()\n", errno,
|
|
1005 |
+ strerror(errno));
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
|
|
1009 |
-void avc1394_vcr_eject(raw1394handle_t handle, nodeid_t node)
|
|
1010 |
+void
|
|
1011 |
+avc1394_vcr_eject(raw1394handle_t handle, nodeid_t node)
|
|
1012 |
{
|
|
1013 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
1014 |
- | AVC1394_VCR_COMMAND_LOAD_MEDIUM | AVC1394_VCR_OPERAND_LOAD_MEDIUM_EJECT);
|
|
1015 |
+ if (avc1394_send_command(handle, node, CTLVCR0
|
|
1016 |
+ | AVC1394_VCR_COMMAND_LOAD_MEDIUM
|
|
1017 |
+ | AVC1394_VCR_OPERAND_LOAD_MEDIUM_EJECT) != 0)
|
|
1018 |
+ send_command_failed(errno, "avc1394_vcr_eject");
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
|
|
1022 |
-void avc1394_vcr_record(raw1394handle_t handle, nodeid_t node)
|
|
1023 |
+void
|
|
1024 |
+avc1394_vcr_record(raw1394handle_t handle, nodeid_t node)
|
|
1025 |
{
|
|
1026 |
- avc1394_send_command(handle, node, CTLVCR0
|
|
1027 |
- | AVC1394_VCR_COMMAND_RECORD | AVC1394_VCR_OPERAND_RECORD_RECORD);
|
|
1028 |
+ if (avc1394_send_command(handle, node, CTLVCR0
|
|
1029 |
+ | AVC1394_VCR_COMMAND_RECORD
|
|
1030 |
+ | AVC1394_VCR_OPERAND_RECORD_RECORD) != 0)
|
|
1031 |
+ send_command_failed(errno, "avc1394_vcr_record");
|
|
1032 |
}
|
|
1033 |
|
|
1034 |
-quadlet_t avc1394_vcr_status(raw1394handle_t handle, nodeid_t node)
|
|
1035 |
+quadlet_t
|
|
1036 |
+avc1394_vcr_status(raw1394handle_t handle, nodeid_t node)
|
|
1037 |
{
|
|
1038 |
return avc1394_transaction(handle, node,
|
|
1039 |
STATVCR0 | AVC1394_VCR_COMMAND_TRANSPORT_STATE
|
|
1040 |
| AVC1394_VCR_OPERAND_TRANSPORT_STATE, AVC1394_RETRY);
|
|
1041 |
-
|
|
1042 |
}
|
|
1043 |
|
|
1044 |
-char *avc1394_vcr_decode_status(quadlet_t response)
|
|
1045 |
+char*
|
|
1046 |
+avc1394_vcr_decode_status(quadlet_t response)
|
|
1047 |
{
|
|
1048 |
- /*quadlet_t resp0 = AVC1394_MASK_RESPONSE_OPERAND(response, 0);
|
|
1049 |
- quadlet_t resp1 = AVC1394_MASK_RESPONSE_OPERAND(response, 1);*/
|
|
1050 |
quadlet_t resp2 = AVC1394_MASK_RESPONSE_OPERAND(response, 2);
|
|
1051 |
quadlet_t resp3 = AVC1394_MASK_RESPONSE_OPERAND(response, 3);
|
|
1052 |
|
|
1053 |
@@ -274,25 +352,28 @@
|
|
1054 |
quadlet_t *response;
|
|
1055 |
char *output = NULL;
|
|
1056 |
|
|
1057 |
+ output = malloc(12);
|
|
1058 |
+ if (output == NULL)
|
|
1059 |
+ return NULL;
|
|
1060 |
+
|
|
1061 |
request[0] = STATVCR0 | AVC1394_VCR_COMMAND_TIME_CODE |
|
|
1062 |
AVC1394_VCR_OPERAND_TIME_CODE_STATUS;
|
|
1063 |
request[1] = 0xFFFFFFFF;
|
|
1064 |
- response = avc1394_transaction_block(handle, node, request, 2, AVC1394_RETRY);
|
|
1065 |
- if (response == NULL || response[1] == 0xffffffff) {
|
|
1066 |
- avc1394_transaction_block_close(handle);
|
|
1067 |
+ response =
|
|
1068 |
+ avc1394_transaction_block(handle, node, request, 2, AVC1394_RETRY);
|
|
1069 |
+ if (response == NULL) {
|
|
1070 |
+ free(output);
|
|
1071 |
return NULL;
|
|
1072 |
}
|
|
1073 |
|
|
1074 |
- output = malloc(12);
|
|
1075 |
- if (output)
|
|
1076 |
// consumer timecode format
|
|
1077 |
- sprintf(output, "%2.2x:%2.2x:%2.2x:%2.2x",
|
|
1078 |
+ (void) snprintf(output, 12, "%2.2x:%2.2x:%2.2x:%2.2x",
|
|
1079 |
response[1] & 0x000000ff,
|
|
1080 |
(response[1] >> 8) & 0x000000ff,
|
|
1081 |
(response[1] >> 16) & 0x000000ff,
|
|
1082 |
(response[1] >> 24) & 0x000000ff);
|
|
1083 |
|
|
1084 |
- avc1394_transaction_block_close(handle);
|
|
1085 |
+ free(response);
|
|
1086 |
return output;
|
|
1087 |
}
|
|
1088 |
|
|
1089 |
@@ -307,19 +388,17 @@
|
|
1090 |
AVC1394_VCR_OPERAND_TIME_CODE_STATUS;
|
|
1091 |
request[1] = 0xFFFFFFFF;
|
|
1092 |
response = avc1394_transaction_block(handle, node, request, 2, AVC1394_RETRY);
|
|
1093 |
- if (response == NULL || response[1] == 0xffffffff) {
|
|
1094 |
- avc1394_transaction_block_close(handle);
|
|
1095 |
+ if (response == NULL) {
|
|
1096 |
return -1;
|
|
1097 |
}
|
|
1098 |
|
|
1099 |
// consumer timecode format
|
|
1100 |
- sprintf(output, "%2.2x:%2.2x:%2.2x:%2.2x",
|
|
1101 |
+ (void) sprintf(output, "%2.2x:%2.2x:%2.2x:%2.2x",
|
|
1102 |
response[1] & 0x000000ff,
|
|
1103 |
(response[1] >> 8) & 0x000000ff,
|
|
1104 |
(response[1] >> 16) & 0x000000ff,
|
|
1105 |
(response[1] >> 24) & 0x000000ff);
|
|
1106 |
|
|
1107 |
- avc1394_transaction_block_close(handle);
|
|
1108 |
return 0;
|
|
1109 |
}
|
|
1110 |
|
|
1111 |
@@ -335,13 +414,17 @@
|
|
1112 |
AVC1394_VCR_OPERAND_TIME_CODE_CONTROL;
|
|
1113 |
|
|
1114 |
// consumer timecode format
|
|
1115 |
- sscanf(timecode, "%2x:%2x:%2x:%2x", &hh, &mm, &ss, &ff);
|
|
1116 |
+ if (sscanf(timecode, "%2x:%2x:%2x:%2x", &hh, &mm, &ss, &ff) != 4)
|
|
1117 |
+ solaris_bad_error(__FILE__, __LINE__, "sscanf", 0);
|
|
1118 |
+
|
|
1119 |
request[1] =
|
|
1120 |
((ff & 0x000000ff) << 24) |
|
|
1121 |
((ss & 0x000000ff) << 16) |
|
|
1122 |
((mm & 0x000000ff) << 8) |
|
|
1123 |
((hh & 0x000000ff) << 0) ;
|
|
1124 |
- printf("timecode: %08x\n", request[1]);
|
|
1125 |
+ (void) fprintf(stderr, "timecode: %08x\n", request[1]);
|
|
1126 |
|
|
1127 |
- avc1394_send_command_block( handle, node, request, 2);
|
|
1128 |
+ if (avc1394_send_command_block( handle, node, request, 2) != 0)
|
|
1129 |
+ send_command_failed(errno, "avc1394_vcr_seek_timecode");
|
|
1130 |
}
|
|
1131 |
+
|
|
1132 |
diff -ur libavc1394-0.5.3.orig/librom1394/rom1394_internal.h libavc1394-0.5.3/librom1394/rom1394_internal.h
|
|
1133 |
--- libavc1394-0.5.3.orig/librom1394/rom1394_internal.h 2006-04-13 23:16:41.000000000 +0700
|
|
1134 |
+++ libavc1394-0.5.3/librom1394/rom1394_internal.h 2007-09-30 21:17:18.895748546 +0700
|
|
1135 |
@@ -35,10 +35,10 @@
|
|
1136 |
#define NODECHECK(handle, node) \
|
|
1137 |
if ( ((int16_t) node < 0) || node >= raw1394_get_nodecount( (raw1394handle_t) handle)) FAIL(node,"invalid node");
|
|
1138 |
#ifdef ROM1394_DEBUG
|
|
1139 |
-#define DEBUG(node, s, args...) \
|
|
1140 |
-printf("rom1394_%i debug: " s "\n", node, ## args)
|
|
1141 |
+#define DEBUG(node, s, args, ...) \
|
|
1142 |
+printf("rom1394_%i debug: " s "\n", node, ##args)
|
|
1143 |
#else
|
|
1144 |
-#define DEBUG(node, s, args...)
|
|
1145 |
+#define DEBUG(node, s, args, ...)
|
|
1146 |
#endif
|
|
1147 |
|
|
1148 |
int
|
|
1149 |
diff -ur libavc1394-0.5.3.orig/librom1394/rom1394_main.c libavc1394-0.5.3/librom1394/rom1394_main.c
|
|
1150 |
--- libavc1394-0.5.3.orig/librom1394/rom1394_main.c 2006-04-13 23:16:41.000000000 +0700
|
|
1151 |
+++ libavc1394-0.5.3/librom1394/rom1394_main.c 2007-09-30 21:12:13.684762999 +0700
|
|
1152 |
@@ -25,12 +25,18 @@
|
|
1153 |
#include "rom1394.h"
|
|
1154 |
#include "rom1394_internal.h"
|
|
1155 |
#include "../common/raw1394util.h"
|
|
1156 |
+#include <libraw1394/csr.h>
|
|
1157 |
+#include <libraw1394/solaris.h>
|
|
1158 |
+
|
|
1159 |
#include <netinet/in.h>
|
|
1160 |
#include <stdio.h>
|
|
1161 |
#include <stdlib.h>
|
|
1162 |
#include <string.h>
|
|
1163 |
#include <malloc.h>
|
|
1164 |
#include <math.h>
|
|
1165 |
+#if defined(sun) || defined(__sun)
|
|
1166 |
+#include <sys/av/iec61883.h>
|
|
1167 |
+#endif
|
|
1168 |
|
|
1169 |
#define MAXLINE 80
|
|
1170 |
#define MAX_OFFSETS 256
|
|
1171 |
@@ -53,16 +59,16 @@
|
|
1172 |
|
|
1173 |
quadlet_t rom1394_get_bus_id(raw1394handle_t handle, nodeid_t node)
|
|
1174 |
{
|
|
1175 |
+ int fd;
|
|
1176 |
quadlet_t quadlet;
|
|
1177 |
- octlet_t offset;
|
|
1178 |
|
|
1179 |
- NODECHECK(handle, node);
|
|
1180 |
- offset = CSR_REGISTER_BASE + CSR_CONFIG_ROM + ROM1394_BUS_ID;
|
|
1181 |
- QUADREADERR (handle, node, offset, &quadlet);
|
|
1182 |
- quadlet = htonl (quadlet);
|
|
1183 |
+ fd = solaris_get_fd(handle, node, 1);
|
|
1184 |
+ if (fd < 0)
|
|
1185 |
+ return -1;
|
|
1186 |
+
|
|
1187 |
+ if (ioctl(fd, IEC61883_NODE_GET_BUS_NAME, &quadlet) != 0)
|
|
1188 |
+ return -1;
|
|
1189 |
|
|
1190 |
- if (quadlet != 0x31333934)
|
|
1191 |
- WARN (node, "invalid bus id", offset);
|
|
1192 |
return quadlet;
|
|
1193 |
}
|
|
1194 |
|
|
1195 |
@@ -87,20 +93,15 @@
|
|
1196 |
|
|
1197 |
octlet_t rom1394_get_guid(raw1394handle_t handle, nodeid_t node)
|
|
1198 |
{
|
|
1199 |
- quadlet_t quadlet;
|
|
1200 |
- octlet_t offset;
|
|
1201 |
+ int fd;
|
|
1202 |
octlet_t guid = 0;
|
|
1203 |
|
|
1204 |
- NODECHECK(handle, node);
|
|
1205 |
- offset = CSR_REGISTER_BASE + CSR_CONFIG_ROM + ROM1394_GUID_HI;
|
|
1206 |
- QUADREADERR (handle, node, offset, &quadlet);
|
|
1207 |
- quadlet = htonl (quadlet);
|
|
1208 |
- guid = quadlet;
|
|
1209 |
- guid <<= 32;
|
|
1210 |
- offset = CSR_REGISTER_BASE + CSR_CONFIG_ROM + ROM1394_GUID_LO;
|
|
1211 |
- QUADREADERR (handle, node, offset, &quadlet);
|
|
1212 |
- quadlet = htonl (quadlet);
|
|
1213 |
- guid += quadlet;
|
|
1214 |
+ fd = solaris_get_fd(handle, node, 1);
|
|
1215 |
+ if (fd < 0)
|
|
1216 |
+ return -1;
|
|
1217 |
+
|
|
1218 |
+ if (ioctl(fd, IEC61883_NODE_GET_UID, &guid) != 0)
|
|
1219 |
+ return -1;
|
|
1220 |
|
|
1221 |
return guid;
|
|
1222 |
}
|
|
1223 |
@@ -361,3 +362,4 @@
|
|
1224 |
|
|
1225 |
return 0;
|
|
1226 |
}
|
|
1227 |
+
|