OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2007-2009 NVIDIA Corporation. |
| 3 * All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: |
| 7 * |
| 8 * Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. |
| 10 * |
| 11 * Redistributions in binary form must reproduce the above copyright notice, |
| 12 * this list of conditions and the following disclaimer in the documentation |
| 13 * and/or other materials provided with the distribution. |
| 14 * |
| 15 * Neither the name of the NVIDIA Corporation nor the names of its contributors |
| 16 * may be used to endorse or promote products derived from this software |
| 17 * without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 * POSSIBILITY OF SUCH DAMAGE. |
| 30 * |
| 31 */ |
| 32 |
| 33 /** |
| 34 * @file |
| 35 * <b>NVIDIA Driver Development Kit: |
| 36 * Key Board Controller (KBC) Interface</b> |
| 37 * |
| 38 * @b Description: Declares interface for the KBC DDK module. |
| 39 * |
| 40 */ |
| 41 |
| 42 #ifndef INCLUDED_NVDDK_KBC_H |
| 43 #define INCLUDED_NVDDK_KBC_H |
| 44 |
| 45 |
| 46 #if defined(__cplusplus) |
| 47 extern "C" |
| 48 { |
| 49 #endif |
| 50 |
| 51 #include "nvrm_init.h" |
| 52 #include "nvcommon.h" |
| 53 #include "nvos.h" |
| 54 |
| 55 /** |
| 56 * @defgroup nvddk_kbc Keyboard Controller Interface |
| 57 * |
| 58 * This is the interface to a hardware keyboard controller. |
| 59 * This keeps track of the keys that are pressed. Only one |
| 60 * client is allowed at a time. |
| 61 * |
| 62 * @ingroup nvddk_modules |
| 63 * @{ |
| 64 */ |
| 65 |
| 66 /** |
| 67 * An opaque context to the NvDdkKbcRec interface. |
| 68 */ |
| 69 typedef struct NvDdkKbcRec *NvDdkKbcHandle; |
| 70 |
| 71 typedef enum |
| 72 { |
| 73 |
| 74 /// Indicates the key press event. |
| 75 NvDdkKbcKeyEvent_KeyPress = 1, |
| 76 |
| 77 /// Indicates the key release event. |
| 78 NvDdkKbcKeyEvent_KeyRelease, |
| 79 |
| 80 /// Indicates key event none. |
| 81 NvDdkKbcKeyEvent_None, |
| 82 NvDdkKbcKeyEvent_Num, |
| 83 /// Ignore -- Forces compilers to make 32-bit enums. |
| 84 NvDdkKbcKeyEvent_Force32 = 0x7FFFFFFF |
| 85 } NvDdkKbcKeyEvent; |
| 86 |
| 87 /** |
| 88 * Initializes the keyboard controller. |
| 89 * It allocates resources such as memory, mutexes, and sets up the |
| 90 * KBC handle. |
| 91 * |
| 92 * @param hDevice Handle to the Rm device that is required by NvDDK |
| 93 * to acquire the resources from RM. |
| 94 * @param phKbc A pointer to the KBC handle where the |
| 95 * allocated handle is stored. The memory for the handle is |
| 96 * allocated inside this API. |
| 97 * |
| 98 * @retval NvSuccess Open is successful. |
| 99 */ |
| 100 NvError NvDdkKbcOpen( |
| 101 NvRmDeviceHandle hDevice, |
| 102 NvDdkKbcHandle * phKbc ); |
| 103 |
| 104 /** |
| 105 * Releases the KBC handle and releases any resources that |
| 106 * are acquired during the NvDdkKbcOpen() call. |
| 107 * |
| 108 * @param hKbc A KBC handle that is allocated by NvDdkKbcOpen(). |
| 109 */ |
| 110 |
| 111 void NvDdkKbcClose( |
| 112 NvDdkKbcHandle hKbc ); |
| 113 |
| 114 /** |
| 115 * Enables the keyboard controller. This must be called once to |
| 116 * receive the key events. |
| 117 * |
| 118 * @param hKbc A KBC handle that is allocated by NvDdkKbcOpen(). |
| 119 * @param SemaphoreId Semaphore to be signaled on any key event. |
| 120 * |
| 121 * @retval NvSuccess KBC is enabled successfully. |
| 122 */ |
| 123 NvError NvDdkKbcStart( |
| 124 NvDdkKbcHandle hKbc, |
| 125 NvOsSemaphoreHandle SemaphoreId ); |
| 126 |
| 127 /** |
| 128 * Disables the keyboard controller. This must be called to |
| 129 * stop receiving the key events. |
| 130 * |
| 131 * @param hKbc A KBC handle that is allocated by NvDdkKbcOpen(). |
| 132 * |
| 133 * @retval NvSuccess KBC is disabled successfully. |
| 134 */ |
| 135 NvError NvDdkKbcStop( |
| 136 NvDdkKbcHandle hKbc ); |
| 137 |
| 138 /** |
| 139 * Sets the repeat time period at which rows must be scanned for key |
| 140 * events. |
| 141 * |
| 142 * @param hKbc A KBC handle that is allocated by NvDdkKbcOpen(). |
| 143 * @param RepeatTimeMs Repeat time period in milliseconds. |
| 144 */ |
| 145 void NvDdkKbcSetRepeatTime( |
| 146 NvDdkKbcHandle hKbc, |
| 147 NvU32 RepeatTimeMs ); |
| 148 |
| 149 /** |
| 150 * Gets the key events. After calling this function, the caller must sleep |
| 151 * for the amount of time returned by this function before calling it again. |
| 152 * If the return value is 0, then the client must wait on sema before |
| 153 * calling this function again. |
| 154 * |
| 155 * @param hKbc A KBC handle that is allocated by NvDdkKbcOpen(). |
| 156 * @param pKeyCount The returned key events count. |
| 157 * @param pKeyCodes The returned key codes. |
| 158 * @param pKeyEvents The returned key events( press/release). |
| 159 * |
| 160 * @return Wait time in milliseconds. |
| 161 */ |
| 162 NvU32 NvDdkKbcGetKeyEvents( |
| 163 NvDdkKbcHandle hKbc, |
| 164 NvU32 * pKeyCount, |
| 165 NvU32 * pKeyCodes, |
| 166 NvDdkKbcKeyEvent * pKeyEvents ); |
| 167 |
| 168 /** |
| 169 * Part of static power management, the client must call this API to put |
| 170 * the KBC controller into suspend state. This API is a mechanism for the |
| 171 * client to augment OS power management policy. The h/w context of the KBC |
| 172 * controller is saved, clock is disabled, and power is also disabled |
| 173 * to the controller. |
| 174 * |
| 175 * @param hKbc A KBC handle that is allocated by NvDdkKbcOpen(). |
| 176 * @retval NvSuccess If successful, or the appropriate error code. |
| 177 */ |
| 178 NvError NvDdkKbcSuspend( |
| 179 NvDdkKbcHandle hKbc ); |
| 180 |
| 181 /** |
| 182 * Part of static power management, the client must call this API to |
| 183 * wake up the KBC controller from a suspended state. This API is |
| 184 * a mechanism for the client to augment OS power management policy. |
| 185 * The h/w context of the KBC controller is restored, clock is enabled, |
| 186 * and power is also enabled to the controller. |
| 187 * |
| 188 * @param hKbc A KBC handle that is allocated by NvDdkKbcOpen(). |
| 189 * @retval NvSuccess If successful, or the appropriate error code. |
| 190 */ |
| 191 NvError NvDdkKbcResume( |
| 192 NvDdkKbcHandle hKbc ); |
| 193 |
| 194 #if defined(__cplusplus) |
| 195 } |
| 196 #endif |
| 197 |
| 198 /** @} */ |
| 199 #endif |
OLD | NEW |