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, void *arg);
38 
39 /* Execute the given callback on each GPIO device.
40  *
41  * Args:
42  *    callback - The callback to execute.
43  *    arg - An argument to pass to the callback.
44  */
45 void gpio_switch_list_for_each(gpio_switch_list_callback callback, void *arg);
46 
47 #endif
48