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 / iso.c < prev    next >
C/C++ Source or Header  |  2000-11-29  |  2KB  |  75 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.  
  20. static int do_iso_listen(struct raw1394_handle *handle, int channel)
  21. {
  22.         struct sync_cb_data sd = { 0, 0 };
  23.         struct raw1394_reqhandle rh = { (req_callback_t)_raw1394_sync_cb, &sd };
  24.         int err;
  25.         struct raw1394_request *req = &handle->req;
  26.  
  27.         CLEAR_REQ(req);
  28.         req->type = RAW1394_REQ_ISO_LISTEN;
  29.         req->generation = handle->generation;
  30.         req->misc = channel;
  31.         req->tag = (__u64)&rh;
  32.         req->recvb = (__u64)handle->buffer;
  33.         req->length = HBUF_SIZE;
  34.  
  35.         err = write(handle->fd, req, sizeof(*req));
  36.         while (!sd.done) {
  37.                 if (err < 0) return err;
  38.                 err = raw1394_loop_iterate(handle);
  39.         }
  40.  
  41.         switch (sd.errcode) {
  42.         case RAW1394_ERROR_ALREADY:
  43.                 errno = EALREADY;
  44.                 return -1;
  45.  
  46.         case RAW1394_ERROR_INVALID_ARG:
  47.                 errno = EINVAL;
  48.                 return -1;
  49.  
  50.         default:
  51.                 errno = 0;
  52.                 return sd.errcode;
  53.         }
  54. }
  55.  
  56. int raw1394_start_iso_rcv(struct raw1394_handle *handle, unsigned int channel)
  57. {
  58.         if (channel > 63) {
  59.                 errno = EINVAL;
  60.                 return -1;
  61.         }
  62.  
  63.         return do_iso_listen(handle, channel);
  64. }
  65.  
  66. int raw1394_stop_iso_rcv(struct raw1394_handle *handle, unsigned int channel)
  67. {
  68.         if (channel > 63) {
  69.                 errno = EINVAL;
  70.                 return -1;
  71.         }
  72.  
  73.         return do_iso_listen(handle, ~channel);
  74. }
  75.