1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <boot/boot.h> 18 #include <boot/board.h> 19 #include <boot/gpio_keypad.h> 20 21 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 22 static unsigned int dream_row_gpios[] = { 23 #if 0 // unused? 24 35, /* KP_MKOUT0 */ 25 34, /* KP_MKOUT1 */ 26 33, /* KP_MKOUT2 */ 27 32, /* KP_MKOUT3 */ 28 31, /* KP_MKOUT4 */ 29 23, /* KP_MKOUT5 */ 30 #endif 31 #if 1 32 30, /* KP_MKOUT6 */ 33 78, /* KP_MKOUT7 */ 34 #endif 35 }; 36 37 static unsigned int dream_col_gpios[] = { 38 #if 1 // main buttons 39 42, /* KP_MKIN0 */ 40 41, /* KP_MKIN1 */ 41 40, /* KP_MKIN2 */ 42 39, /* KP_MKIN3 */ 43 #endif 44 #if 1 // side buttons 45 38, /* KP_MKIN4 */ 46 37, /* KP_MKIN5 */ 47 36, /* KP_MKIN6 */ 48 #endif 49 }; 50 static gpio_keypad_info dream_keypad = { 51 .output_gpios = dream_row_gpios, 52 .input_gpios = dream_col_gpios, 53 .noutputs = ARRAY_SIZE(dream_row_gpios), 54 .ninputs = ARRAY_SIZE(dream_col_gpios), 55 .settle_time = 5000, 56 .polarity = 0 57 }; 58 59 static void keypad_poll() 60 { 61 static int skip = 0; 62 skip++; 63 if(skip > 10) { 64 gpio_keypad_scan_keys(&dream_keypad); 65 skip = 0; 66 } 67 } 68 69 70 void keypad_init(void) 71 { 72 gpio_keypad_init(&dream_keypad); 73 boot_register_poll_func(keypad_poll); 74 } 75