1 /* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2 * Use of this source code is governed by a BSD-style license that can be 3 * found in the LICENSE file. 4 */ 5 6 #ifndef _CRAS_GPIO_JACK_H 7 #define _CRAS_GPIO_JACK_H 8 9 #include "cras_types.h" 10 11 struct mixer_name; 12 13 int gpio_switch_open(const char *pathname); 14 int gpio_switch_read(int fd, void *buf, size_t n_bytes); 15 16 int gpio_switch_eviocgbit(int fd, void *buf, size_t n_bytes); 17 int gpio_switch_eviocgsw(int fd, void *bits, size_t n_bytes); 18 19 /* sys_input_get_device_name: 20 * 21 * Returns the heap-allocated device name of a /dev/input/event* 22 * pathname. Caller is responsible for releasing. 23 */ 24 char *sys_input_get_device_name(const char *path); 25 26 /* List for each callback function. 27 * 28 * Args: 29 * dev_path - Full path to the GPIO device. 30 * dev_name - The name of the GPIO device. 31 * arg - The argument passed to gpio_switch_list_for_each. 32 * 33 * Returns: 34 * 0 to continue searching, non-zero otherwise. 35 */ 36 typedef int (*gpio_switch_list_callback)(const char *dev_path, 37 const char *dev_name, 38 void *arg); 39 40 /* Execute the given callback on each GPIO device. 41 * 42 * Args: 43 * callback - The callback to execute. 44 * arg - An argument to pass to the callback. 45 */ 46 void gpio_switch_list_for_each(gpio_switch_list_callback callback, void *arg); 47 48 #endif 49