"Fossies" - the Fresh Open Source Software Archive

Member "usbutils-015/usbhid-dump/src/iface.h" (22 Feb 2021, 4928 Bytes) of package /linux/misc/usbutils-015.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "iface.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 013_vs_014.

    1 // SPDX-License-Identifier: GPL-2.0-or-later
    2 /*
    3  * usbhid-dump - interface
    4  *
    5  * Copyright (C) 2010 Nikolai Kondrashov <spbnick@gmail.com>
    6  */
    7 
    8 #ifndef __UHD_IFACE_H__
    9 #define __UHD_IFACE_H__
   10 
   11 #include <stdint.h>
   12 #include "dev.h"
   13 
   14 #ifdef __cplusplus
   15 extern "C" {
   16 #endif
   17 
   18 /** usbhid-dump interface */
   19 typedef struct uhd_iface uhd_iface;
   20 
   21 struct uhd_iface {
   22     uhd_iface              *next;
   23     const uhd_dev          *dev;            /**< Device */
   24     uint8_t                 number;         /**< Interface number */
   25     char                    addr_str[12];   /**< Address string */
   26     uint8_t                 int_in_ep_addr; /**< Interrupt IN EP address */
   27     uint16_t                int_in_ep_maxp; /**< Interrupt IN EP maximum
   28                                                  packet size */
   29     uint16_t                rd_len;         /**< Report descriptor length */
   30     bool                    detached;       /**< True if the interface was
   31                                                  detached from the kernel
   32                                                  driver, false otherwise */
   33     bool                    claimed;        /**< True if the interface was
   34                                                  claimed */
   35     /*
   36      * This is somewhat hackish and doesn't belong here, since theoretically
   37      * there could be more than one transfer submitted for an interface.
   38      * However, we don't do it yet. This flag is used to track transfer
   39      * cancellation during stream dumping.
   40      */
   41     bool                    submitted;      /**< True if an asynchronous
   42                                                  transfer has been submitted
   43                                                  for the interface */
   44 };
   45 
   46 /**
   47  * Check if an interface is valid.
   48  *
   49  * @param iface Interface.
   50  *
   51  * @return True if the interface is valid, false otherwise.
   52  */
   53 extern bool uhd_iface_valid(const uhd_iface *iface);
   54 
   55 /**
   56  * Create a new interface.
   57  *
   58  * @param handle            Device handle.
   59  * @param number            Interface number.
   60  * @param int_in_ep_addr    Interrupt in endpoint address.
   61  * @param int_in_ep_maxp    Interrupt in endpoint maximum packet size.
   62  * @param rd_len            Report descriptor length.
   63  *
   64  * @return New interface or NULL, if failed to allocate.
   65  */
   66 extern uhd_iface *uhd_iface_new(const uhd_dev  *dev,
   67                                 uint8_t         number,
   68                                 uint8_t         int_in_ep_addr,
   69                                 uint16_t        int_in_ep_maxp,
   70                                 uint16_t        rd_len);
   71 
   72 /**
   73  * Free an interface.
   74  *
   75  * @param iface The interface to free, could be NULL.
   76  */
   77 extern void uhd_iface_free(uhd_iface *iface);
   78 
   79 /**
   80  * Detach an interface from its kernel driver (if any).
   81  *
   82  * @param iface The interface to detach.
   83  *
   84  * @return Libusb error code.
   85  */
   86 extern enum libusb_error uhd_iface_detach(uhd_iface *iface);
   87 
   88 /**
   89  * Attach an interface to its kernel driver (if detached before).
   90  *
   91  * @param iface The interface to attach.
   92  *
   93  * @return Libusb error code.
   94  */
   95 extern enum libusb_error uhd_iface_attach(uhd_iface *iface);
   96 
   97 /**
   98  * Claim an interface.
   99  *
  100  * @param iface The interface to claim.
  101  *
  102  * @return Libusb error code.
  103  */
  104 extern enum libusb_error uhd_iface_claim(uhd_iface *iface);
  105 
  106 /**
  107  * Set idle duration on an interface; ignore errors indicating missing
  108  * support.
  109  *
  110  * @param iface     The interface to set idle duration on.
  111  * @param duration  The duration in 4 ms steps starting from 4 ms.
  112  * @param timeout   The request timeout, ms.
  113  *
  114  * @return Libusb error code.
  115  */
  116 extern enum libusb_error uhd_iface_set_idle(
  117                                        const uhd_iface    *iface,
  118                                        uint8_t             duration,
  119                                        unsigned int        timeout);
  120 
  121 /**
  122  * Set HID protocol on an interface; ignore errors indicating missing
  123  * support.
  124  *
  125  * @param iface     The interface to set idle duration on.
  126  * @param report    True for "report" protocol, false for "boot" protocol.
  127  * @param timeout   The request timeout, ms.
  128  *
  129  * @return Libusb error code.
  130  */
  131 extern enum libusb_error uhd_iface_set_protocol(
  132                                        const uhd_iface    *iface,
  133                                        bool                report,
  134                                        unsigned int        timeout);
  135 
  136 /**
  137  * Clear halt condition on the input interrupt endpoint of an interface.
  138  *
  139  * @param iface The interface to clear halt condition on.
  140  *
  141  * @return Libusb error code.
  142  */
  143 extern enum libusb_error uhd_iface_clear_halt(uhd_iface *iface);
  144 
  145 /**
  146  * Release an interface (if claimed before).
  147  *
  148  * @param iface The interface to release.
  149  *
  150  * @return Libusb error code.
  151  */
  152 extern enum libusb_error uhd_iface_release(uhd_iface *iface);
  153 
  154 #ifdef __cplusplus
  155 } /* extern "C" */
  156 #endif
  157 
  158 #endif /* __UHD_IFACE_H__ */