home *** CD-ROM | disk | FTP | other *** search
/ Geek 6 / Geek-006.iso / linux / video / xmovie-1.5.3.tar.gz / xmovie-1.5.3.tar / xmovie-1.5.3 / quicktime / libraw1394.2217 / fcp.c < prev    next >
C/C++ Source or Header  |  2000-11-29  |  2KB  |  64 lines

  1. /*
  2.  * libraw1394 - library for raw access to the 1394 bus with the Linux subsystem.
  3.  *
  4.  * Copyright (C) 1999,2000 Andreas Bombe
  5.  *
  6.  * This library is licensed under the GNU Lesser General Public License (LGPL),
  7.  * version 2.1 or later. See the file COPYING.LIB in the distribution for
  8.  * details.
  9.  */
  10.  
  11. #include <config.h>
  12. #include <errno.h>
  13. #include <unistd.h>
  14.  
  15. #include "raw1394.h"
  16. #include "kernel-raw1394.h"
  17. #include "raw1394_private.h"
  18.  
  19. static int do_fcp_listen(struct raw1394_handle *handle, int startstop)
  20. {
  21.         struct sync_cb_data sd = { 0, 0 };
  22.         struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd };
  23.         int err;
  24.         struct raw1394_request *req = &handle->req;
  25.  
  26.         CLEAR_REQ(req);
  27.         req->type = RAW1394_REQ_FCP_LISTEN;
  28.         req->generation = handle->generation;
  29.         req->misc = startstop;
  30.         req->tag = (__u64)&rh;
  31.         req->recvb = (__u64)handle->buffer;
  32.         req->length = 512;
  33.  
  34.         err = write(handle->fd, req, sizeof(*req));
  35.         while (!sd.done) {
  36.                 if (err < 0) return err;
  37.                 err = raw1394_loop_iterate(handle);
  38.         }
  39.  
  40.         switch (sd.errcode) {
  41.         case RAW1394_ERROR_ALREADY:
  42.                 errno = EALREADY;
  43.                 return -1;
  44.  
  45.         case RAW1394_ERROR_INVALID_ARG:
  46.                 errno = EINVAL;
  47.                 return -1;
  48.  
  49.         default:
  50.                 errno = 0;
  51.                 return sd.errcode;
  52.         }
  53. }
  54.  
  55. int raw1394_start_fcp_listen(struct raw1394_handle *handle)
  56. {
  57.         return do_fcp_listen(handle, 1);
  58. }
  59.  
  60. int raw1394_stop_fcp_listen(struct raw1394_handle *handle)
  61. {
  62.         return do_fcp_listen(handle, 0);
  63. }
  64.