Ignore:
Timestamp:
2018-02-28T16:37:50Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b20da0
Parents:
f5e5f73 (diff), b2dca8de (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jakub Jermar <jakub@…> (2018-02-28 16:06:42)
git-committer:
Jakub Jermar <jakub@…> (2018-02-28 16:37:50)
Message:

Merge github.com:helenos-xhci-team/helenos

This commit merges support for USB 3 and generally refactors, fixes,
extends and cleans up the existing USB framework.

Notable additions and features:

  • new host controller driver has been implemented to control various xHC models (among others, NEC Renesas uPD720200)
  • isochronous data transfer mode
  • support for explicit USB device removal
  • USB tablet driver
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/poll.h

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2011 Vojtech Horky
     3 * Copyright (c) 2017 Petr Manek
    34 * All rights reserved.
    45 *
     
    4344#include <stddef.h>
    4445#include <stdint.h>
     46#include <fibril_synch.h>
    4547
    46 /** Parameters and callbacks for automated polling. */
    47 typedef struct {
    48         /** Level of debugging messages from auto polling.
    49          * 0 - nothing
    50          * 1 - inform about errors and polling start/end
    51          * 2 - also dump every retrieved buffer
     48
     49/** USB automated polling. */
     50typedef struct usb_polling {
     51        /** Mandatory parameters - user is expected to configure these. */
     52
     53        /** USB device to poll. */
     54        usb_device_t *device;
     55
     56        /** Device enpoint mapping to use for polling. */
     57        usb_endpoint_mapping_t *ep_mapping;
     58
     59        /** Size of the recieved data. */
     60        size_t request_size;
     61
     62        /**
     63         * Data buffer of at least `request_size`. User is responsible for its
     64         * allocation.
    5265         */
    53         int debug;
    54         /** Maximum number of consecutive errors before polling termination. */
    55         size_t max_failures;
    56         /** Delay between poll requests in milliseconds.
    57          * Set to negative value to use value from endpoint descriptor.
    58          */
    59         int delay;
    60         /** Whether to automatically try to clear the HALT feature after
    61          * the endpoint stalls.
    62          */
    63         bool auto_clear_halt;
     66        uint8_t *buffer;
     67
    6468        /** Callback when data arrives.
    6569         *
     
    7276        bool (*on_data)(usb_device_t *dev, uint8_t *data, size_t data_size,
    7377            void *arg);
     78
     79
     80        /**
     81         * Optional parameters - user can customize them, but they are
     82         * defaulted to  some reasonable values.
     83         */
     84
     85        /** Level of debugging messages from auto polling.
     86         * 0 - nothing (default)
     87         * 1 - inform about errors and polling start/end
     88         * 2 - also dump every retrieved buffer
     89         */
     90        int debug;
     91
     92        /**
     93         * Maximum number of consecutive errors before polling termination
     94         * (default 3).
     95         */
     96        size_t max_failures;
     97
     98        /** Delay between poll requests in milliseconds.
     99         * By default, value from endpoint descriptor used.
     100         */
     101        int delay;
     102
     103        /** Whether to automatically try to clear the HALT feature after
     104         * the endpoint stalls (true by default).
     105         */
     106        bool auto_clear_halt;
     107
     108        /** Argument to pass to callbacks (default NULL). */
     109        void *arg;
     110
    74111        /** Callback when polling is terminated.
    75112         *
     
    80117        void (*on_polling_end)(usb_device_t *dev, bool due_to_errors,
    81118            void *arg);
     119
    82120        /** Callback when error occurs.
    83121         *
     
    88126         */
    89127        bool (*on_error)(usb_device_t *dev, errno_t err_code, void *arg);
    90         /** Argument to pass to callbacks. */
    91         void *arg;
    92 } usb_device_auto_polling_t;
    93128
    94 typedef bool (*usb_polling_callback_t)(usb_device_t *, uint8_t *, size_t, void *);
    95 typedef void (*usb_polling_terminted_callback_t)(usb_device_t *, bool, void *);
    96129
    97 extern errno_t usb_device_auto_polling(usb_device_t *, usb_endpoint_t,
    98     const usb_device_auto_polling_t *, size_t);
     130        /**
     131         * Internal parameters - user is not expected to set them. Messing with
     132         * them can result in unexpected behavior if you do not know what you
     133         * are doing.
     134         */
    99135
    100 extern errno_t usb_device_auto_poll(usb_device_t *, usb_endpoint_t,
    101     usb_polling_callback_t, size_t, int, usb_polling_terminted_callback_t, void *);
     136        /** Fibril used for polling. */
     137        fid_t fibril;
    102138
    103 extern errno_t usb_device_auto_polling_desc(usb_device_t *,
    104     const usb_endpoint_description_t *, const usb_device_auto_polling_t *,
    105     size_t);
     139        /** True if polling is currently in operation. */
     140        volatile bool running;
    106141
    107 extern errno_t usb_device_auto_poll_desc(usb_device_t *,
    108     const usb_endpoint_description_t *, usb_polling_callback_t, size_t, int,
    109     usb_polling_terminted_callback_t, void *);
     142        /** True if polling should terminate as soon as possible. */
     143        volatile bool joining;
     144
     145        /** Synchronization primitives for joining polling end. */
     146        fibril_mutex_t guard;
     147        fibril_condvar_t cv;
     148} usb_polling_t;
     149
     150errno_t usb_polling_init(usb_polling_t *);
     151void usb_polling_fini(usb_polling_t *);
     152
     153errno_t usb_polling_start(usb_polling_t *);
     154errno_t usb_polling_join(usb_polling_t *);
    110155
    111156#endif
Note: See TracChangeset for help on using the changeset viewer.