tizen 2.3 release
[framework/system/deviced.git] / src / usb / usb-client.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #ifndef __USB_CLIENT_H__
20 #define __USB_CLIENT_H__
21
22 #include <stdbool.h>
23 #include <device-node.h>
24
25 #include "core/log.h"
26 #include "core/devices.h"
27 #include "display/poll.h"
28 #include "core/udev.h"
29 #include "core/common.h"
30 #include "core/list.h"
31 #include "apps/apps.h"
32 #include "usb-common.h"
33
34 /* Switch uevent */
35 #define UDEV_PROP_KEY_SWITCH_NAME  "SWITCH_NAME"
36 #define UDEV_PROP_VALUE_USB_CABLE  "usb_cable"
37
38 #define UDEV_PROP_KEY_SWITCH_STATE "SWITCH_STATE"
39 #define UDEV_PROP_VALUE_DISCON     "0"
40 #define UDEV_PROP_VALUE_CON        "1"
41
42 /* usb_mode uevnet */
43 #define USBMODE_SUBSYSTEM          "usb_mode"
44 #define UDEV_PROP_KEY_USB_STATE    "USB_STATE"
45 #define UDEV_PROP_VALUE_CONFIGURED "CONFIGURED"
46
47 /* Platform uevent */
48 #define UDEV_PROP_KEY_CHGDET       "CHGDET"
49 #define UDEV_PROP_VALUE_USB        "usb"
50
51 #define USB_CON_START  "start"
52 #define USB_CON_STOP   "stop"
53
54 #define USB_RESTRICT  "restrict"
55 #define USB_ERROR     "error"
56
57 #define USB_BUF_LEN 64
58
59 #ifndef VCONFKEY_USB_CONFIGURATION_ENABLED
60 #define VCONFKEY_USB_CONFIGURATION_ENABLED "memory/private/usb/conf_enabled"
61 #endif
62
63 enum internal_usb_mode {
64         SET_USB_DIAG_RMNET = 11,
65 };
66
67 enum usbclient_setting_option {
68         SET_CONFIGURATION = 0x01,
69         SET_OPERATION     = 0x02,
70         SET_NOTIFICATION  = 0x04,
71 };
72
73 enum usb_enabled {
74         USB_CONF_DISABLED,
75         USB_CONF_ENABLED,
76 };
77
78 struct usb_configuration {
79         char name[USB_BUF_LEN];
80         char value[USB_BUF_LEN];
81 };
82
83 struct usb_operation {
84         char name[USB_BUF_LEN];
85         char oper[USB_BUF_LEN];
86 };
87
88 /* config */
89 int make_configuration_list(int usb_mode);
90 void release_configuration_list(void);
91 int make_operation_list(int usb_mode, char *action);
92 void release_operations_list(void);
93
94 int get_root_path(char **path);
95 int get_operations_list(dd_list **list);
96 int get_configurations_list(dd_list **list);
97
98 /* vconf callbacks */
99 void client_mode_changed(keynode_t* key, void *data);
100 void prev_client_mode_changed(keynode_t* key, void *data);
101 void debug_mode_changed(keynode_t* key, void *data);
102 void tethering_status_changed(keynode_t* key, void *data);
103
104 /* Check usb state */
105 int get_default_mode(void);
106 int get_current_usb_physical_state(void);
107 int get_current_usb_logical_state(void);
108 int get_current_usb_mode(void);
109 int get_selected_usb_mode(void);
110 int get_debug_mode(void);
111 int change_selected_usb_mode(int mode);
112 int update_current_usb_mode(int mode);
113 int update_usb_state(int state);
114 unsigned int get_current_usb_gadget_info(int mode);
115
116 /* Unset usb mode */
117 void unset_client_mode(int mode, bool change);
118
119 /* USB control */
120 int control_start(enum device_flags flags);
121 int control_stop(enum device_flags flags);
122 int control_status(void);
123 void wait_until_booting_done(void);
124 void usbclient_init_booting_done(void);
125 void act_usb_connected(void);
126 int register_usbclient_dbus_methods(void);
127 void send_msg_usb_state_changed(void);
128 void send_msg_usb_mode_changed(void);
129
130 /* USB syspopup */
131 void launch_syspopup(char *str);
132
133 /* Change usb mode */
134 void change_client_setting(int options);
135 bool get_wait_configured(void);
136
137 /* For SDK */
138 void usb_state_changed(int state);
139
140 #endif /* __USB_CLIENT_H__ */