Skip to content

Latest commit

 

History

History
116 lines (91 loc) · 4.04 KB

usb_moded.h

File metadata and controls

116 lines (91 loc) · 4.04 KB
 
Mar 22, 2011
Mar 22, 2011
1
2
/*
Copyright (C) 2010 Nokia Corporation. All rights reserved.
Nov 7, 2016
Nov 7, 2016
3
Copyright (C) 2012-2016 Jolla. All rights reserved.
Mar 22, 2011
Mar 22, 2011
4
Jun 11, 2014
Jun 11, 2014
5
6
@author: Philippe De Swert <philippe.de-swert@nokia.com>
@author: Philippe De Swert <philippe.deswert@jollamobile.com>
Nov 7, 2016
Nov 7, 2016
7
@author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
Mar 22, 2011
Mar 22, 2011
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
This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA
*/
#ifndef USB_MODED_H_
#define USB_MODED_H_
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <config.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <glib-2.0/glib.h>
#include <glib-object.h>
May 27, 2013
May 27, 2013
41
42
#include "usb_moded-dyn-config.h"
Mar 22, 2011
Mar 22, 2011
43
44
45
#define USB_MODED_LOCKFILE "/var/run/usb_moded.pid"
#define MAX_READ_BUF 512
May 10, 2011
May 10, 2011
46
47
48
/**
* a struct containing all the usb_moded info needed
*/
Mar 22, 2011
Mar 22, 2011
49
50
typedef struct usb_mode
{
May 10, 2011
May 10, 2011
51
/*@{*/
May 27, 2013
May 27, 2013
52
53
gboolean connected; /* connection status, 1 for connected */
gboolean mounted; /* mount status, 1 for mounted -UNUSED atm- */
Jun 2, 2014
Jun 2, 2014
54
gboolean android_usb_broken; /* Used to keep an active gadget for broken Android kernels */
Oct 29, 2013
Oct 29, 2013
55
56
char *mode; /* the mode name */
char *module; /* the module name for the specific mode */
May 27, 2013
May 27, 2013
57
struct mode_list_elem *data; /* contains the mode data */
May 10, 2011
May 10, 2011
58
/*@}*/
Mar 22, 2011
Mar 22, 2011
59
60
}usb_mode;
Aug 11, 2017
Aug 11, 2017
61
62
63
64
65
typedef enum mode_list_type_t {
SUPPORTED_MODES_LIST,
AVAILABLE_MODES_LIST
} mode_list_type_t;
Mar 22, 2011
Mar 22, 2011
66
67
68
void set_usb_connected(gboolean connected);
void set_usb_connected_state(void);
void set_usb_mode(const char *mode);
Feb 14, 2017
Feb 14, 2017
69
void rethink_usb_charging_fallback(void);
Mar 22, 2011
Mar 22, 2011
70
71
72
const char * get_usb_mode(void);
void set_usb_module(const char *module);
const char * get_usb_module(void);
May 27, 2013
May 27, 2013
73
74
void set_usb_mode_data(struct mode_list_elem *data);
struct mode_list_elem * get_usb_mode_data(void);
Mar 22, 2011
Mar 22, 2011
75
gboolean get_usb_connection_state(void);
May 17, 2011
May 17, 2011
76
void set_usb_connection_state(gboolean state);
May 10, 2013
May 10, 2013
77
void set_charger_connected(gboolean state);
Aug 11, 2017
Aug 11, 2017
78
79
gchar *get_mode_list(mode_list_type_t type);
gchar *get_available_mode_list(void);
Oct 30, 2013
Oct 30, 2013
80
int valid_mode(const char *mode);
Mar 22, 2011
Mar 22, 2011
81
Apr 26, 2016
Apr 26, 2016
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/** Name of the wakelock usb_moded uses for temporary suspend delay */
#define USB_MODED_WAKELOCK_STATE_CHANGE "usb_moded_state"
/** Name of the wakelock usb_moded uses for input processing */
#define USB_MODED_WAKELOCK_PROCESS_INPUT "usb_moded_input"
/** How long usb_moded will delay suspend by default [ms] */
#define USB_MODED_SUSPEND_DELAY_DEFAULT_MS 5000
/** How long usb_moded is allowed to block suspend [ms] */
#define USB_MODED_SUSPEND_DELAY_MAXIMUM_MS \
(USB_MODED_SUSPEND_DELAY_DEFAULT_MS * 2)
void acquire_wakelock(const char *wakelock_name);
void release_wakelock(const char *wakelock_name);
void allow_suspend(void);
void delay_suspend(void);
Apr 26, 2016
Apr 26, 2016
100
101
102
extern int cable_connection_delay;
Nov 7, 2016
Nov 7, 2016
103
104
void usb_moded_stop(int exitcode);
Mar 24, 2017
Mar 24, 2017
105
106
107
int usb_moded_system_(const char *file, int line, const char *func, const char *command);
#define usb_moded_system(command) usb_moded_system_(__FILE__,__LINE__,__FUNCTION__,(command))
Mar 24, 2017
Mar 24, 2017
108
109
110
FILE *usb_moded_popen_(const char *file, int line, const char *func, const char *command, const char *type);
#define usb_moded_popen(command, type) usb_moded_popen_(__FILE__,__LINE__,__FUNCTION__,(command),(type))
Mar 24, 2017
Mar 24, 2017
111
112
113
114
115
void usb_moded_usleep_(const char *file, int line, const char *func, useconds_t usec);
#define usb_moded_usleep(usec) usb_moded_usleep_(__FILE__,__LINE__,__FUNCTION__,(usec))
#define usb_moded_msleep(msec) usb_moded_usleep_(__FILE__,__LINE__,__FUNCTION__,(msec)*1000)
#define usb_moded_sleep(sec) usb_moded_usleep_(__FILE__,__LINE__,__FUNCTION__,(sec)*1000000)
Mar 22, 2011
Mar 22, 2011
116
#endif /* USB_MODED_H */