1/*
2 *
3 * @APPLE_LICENSE_HEADER_START@
4 *
5 * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25#ifndef _IOKIT_HID_IOHIDEVENTQUEUE_H
26#define _IOKIT_HID_IOHIDEVENTQUEUE_H
27
28#include <IOKit/IOSharedDataQueue.h>
29#include <IOKit/IOLocks.h>
30#include "IOHIDKeys.h"
31#include "IOHIDElementPrivate.h"
32
33#define DEFAULT_HID_ENTRY_SIZE  sizeof(IOHIDElementValue)+ sizeof(void *)
34#define MIN_HID_QUEUE_CAPACITY  16384
35
36//---------------------------------------------------------------------------
37// IOHIDEventQueue class.
38//
39// IOHIDEventQueue is a subclass of IOSharedDataQueue. But this may change
40// if the HID Manager requires HID specific functionality for the
41// event queueing.
42
43class IOHIDEventQueue: public IOSharedDataQueue
44{
45    OSDeclareDefaultStructors( IOHIDEventQueue )
46
47protected:
48    IOOptionBits            _state;
49
50    IOLock *                _lock;
51
52    UInt32                  _currentEntrySize;
53    UInt32                  _maxEntrySize;
54    UInt32                  _numEntries;
55
56    OSSet *                 _elementSet;
57
58    IOMemoryDescriptor *    _descriptor;
59
60    IOHIDQueueOptionsType   _options;
61
62    struct ExpansionData { };
63    /*! @var reserved
64        Reserved for future use.  (Internal use only)  */
65    ExpansionData * _reserved;
66
67
68public:
69    static IOHIDEventQueue * withCapacity( UInt32 size );
70
71    static IOHIDEventQueue * withEntries( UInt32 numEntries,
72                                          UInt32 entrySize );
73
74    virtual Boolean initWithEntries(UInt32 numEntries, UInt32 entrySize);
75
76    virtual void free();
77
78    virtual Boolean enqueue( void * data, UInt32 dataSize );
79
80    virtual void start();
81    virtual void stop();
82    virtual Boolean isStarted();
83
84    virtual void setOptions(IOHIDQueueOptionsType flags);
85    virtual IOHIDQueueOptionsType getOptions();
86
87    virtual void enable();
88    virtual void disable();
89
90    virtual void addElement( IOHIDElementPrivate * element );
91    virtual void removeElement( IOHIDElementPrivate * element );
92
93    virtual UInt32 getEntrySize ();
94
95    virtual IOMemoryDescriptor *getMemoryDescriptor();
96
97    OSMetaClassDeclareReservedUnused(IOHIDEventQueue,  0);
98    OSMetaClassDeclareReservedUnused(IOHIDEventQueue,  1);
99    OSMetaClassDeclareReservedUnused(IOHIDEventQueue,  2);
100    OSMetaClassDeclareReservedUnused(IOHIDEventQueue,  3);
101    OSMetaClassDeclareReservedUnused(IOHIDEventQueue,  4);
102    OSMetaClassDeclareReservedUnused(IOHIDEventQueue,  5);
103    OSMetaClassDeclareReservedUnused(IOHIDEventQueue,  6);
104    OSMetaClassDeclareReservedUnused(IOHIDEventQueue,  7);
105    OSMetaClassDeclareReservedUnused(IOHIDEventQueue,  8);
106    OSMetaClassDeclareReservedUnused(IOHIDEventQueue,  9);
107    OSMetaClassDeclareReservedUnused(IOHIDEventQueue, 10);
108    OSMetaClassDeclareReservedUnused(IOHIDEventQueue, 11);
109    OSMetaClassDeclareReservedUnused(IOHIDEventQueue, 12);
110    OSMetaClassDeclareReservedUnused(IOHIDEventQueue, 13);
111    OSMetaClassDeclareReservedUnused(IOHIDEventQueue, 14);
112    OSMetaClassDeclareReservedUnused(IOHIDEventQueue, 15);
113};
114
115#endif /* !_IOKIT_HID_IOHIDEVENTQUEUE_H */
116