summaryrefslogtreecommitdiff
path: root/cras/src/server/cras_gpio_jack.h
blob: e6dd8aab6b74784cc936666b6916429c8afbce98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef _CRAS_GPIO_JACK_H
#define _CRAS_GPIO_JACK_H

#include "cras_types.h"

struct mixer_name;

int gpio_switch_open(const char *pathname);
int gpio_switch_read(int fd, void *buf, size_t n_bytes);

int gpio_switch_eviocgbit(int fd, void *buf, size_t n_bytes);
int gpio_switch_eviocgsw(int fd, void *bits, size_t n_bytes);

/* sys_input_get_device_name:
 *
 *   Returns the heap-allocated device name of a /dev/input/event*
 *   pathname.  Caller is responsible for releasing.
 */
char *sys_input_get_device_name(const char *path);

/* List for each callback function.
 *
 * Args:
 *    dev_path - Full path to the GPIO device.
 *    dev_name - The name of the GPIO device.
 *    arg - The argument passed to gpio_switch_list_for_each.
 *
 * Returns:
 *    0 to continue searching, non-zero otherwise.
 */
typedef int (*gpio_switch_list_callback)(const char *dev_path,
					 const char *dev_name, void *arg);

/* Execute the given callback on each GPIO device.
 *
 * Args:
 *    callback - The callback to execute.
 *    arg - An argument to pass to the callback.
 */
void gpio_switch_list_for_each(gpio_switch_list_callback callback, void *arg);

#endif