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 / eventloop.c < prev    next >
C/C++ Source or Header  |  2000-11-29  |  4KB  |  123 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 <unistd.h>
  13.  
  14. #include "raw1394.h"
  15. #include "kernel-raw1394.h"
  16. #include "raw1394_private.h"
  17.  
  18.  
  19. int raw1394_loop_iterate(struct raw1394_handle *handle)
  20. {
  21.         struct raw1394_request *req = &handle->req;
  22.         int retval = 0, channel;
  23.  
  24.         if (read(handle->fd, req, sizeof(*req)) < 0) {
  25.                 return -1;
  26.         }
  27.  
  28.         switch (req->type) {
  29.         case RAW1394_REQ_BUS_RESET:
  30.                 handle->generation = req->generation;
  31.                 handle->num_of_nodes = req->misc & 0xffff;
  32.                 handle->local_id = req->misc >> 16;
  33.  
  34.                 if (handle->bus_reset_handler) {
  35.                         retval = handle->bus_reset_handler(handle);
  36.                 }
  37.                 break;
  38.  
  39.         case RAW1394_REQ_ISO_RECEIVE:
  40.                 channel = (handle->buffer[0] >> 8) & 0x3f;
  41.  
  42.                 if (handle->iso_handler[channel]) {
  43.                         retval = handle->iso_handler[channel](handle, channel,
  44.                                                               req->length,
  45.                                                               handle->buffer);
  46.                 }
  47.                 break;
  48.  
  49.         case RAW1394_REQ_FCP_REQUEST:
  50.                 if (handle->fcp_handler) {
  51.                         retval = handle->fcp_handler(handle, req->misc & 0xffff,
  52.                                                      req->misc >> 16,
  53.                                                      req->length,
  54.                                                      (char *)handle->buffer);
  55.                 }
  56.                 break;
  57.  
  58.         default:
  59.                 if (handle->tag_handler) {
  60.                         retval = handle->tag_handler(handle, req->tag,
  61.                                                      req->error);
  62.                 }
  63.                 break;
  64.         }
  65.  
  66.         return retval;
  67. }
  68.  
  69.  
  70. bus_reset_handler_t raw1394_set_bus_reset_handler(struct raw1394_handle *handle,
  71.                                                   bus_reset_handler_t new)
  72. {
  73.         bus_reset_handler_t old;
  74.  
  75.         old = handle->bus_reset_handler;
  76.         handle->bus_reset_handler = new;
  77.  
  78.         return old;
  79. }
  80.  
  81. tag_handler_t raw1394_set_tag_handler(struct raw1394_handle *handle, 
  82.                                       tag_handler_t new)
  83. {
  84.         tag_handler_t old;
  85.  
  86.         old = handle->tag_handler;
  87.         handle->tag_handler = new;
  88.  
  89.         return old;
  90. }
  91.  
  92. iso_handler_t raw1394_set_iso_handler(struct raw1394_handle *handle,
  93.                                       unsigned int channel, iso_handler_t new)
  94. {
  95.         if (channel >= 64) {
  96.                 return (iso_handler_t)-1;
  97.         }
  98.  
  99.         if (new == NULL) {
  100.                 iso_handler_t old = handle->iso_handler[channel];
  101.                 handle->iso_handler[channel] = NULL;
  102.                 return old;
  103.         }
  104.  
  105.         if (handle->iso_handler[channel] != NULL) {
  106.                 return (iso_handler_t)-1;
  107.         }
  108.  
  109.         handle->iso_handler[channel] = new;
  110.         return NULL;
  111. }
  112.  
  113. fcp_handler_t raw1394_set_fcp_handler(struct raw1394_handle *handle,
  114.                                       fcp_handler_t new)
  115. {
  116.         fcp_handler_t old;
  117.  
  118.         old = handle->fcp_handler;
  119.         handle->fcp_handler = new;
  120.  
  121.         return old;
  122. }
  123.