Initialize Tizen 2.3
[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_SET    "set"
52 #define USB_CON_UNSET  "unset"
53
54 #define USB_RESTRICT  "restrict"
55 #define USB_ERROR     "error"
56
57 //#define USB_DEBUG
58
59 enum usbclient_setting_option {
60         SET_CONFIGURATION = 0x0001,
61         SET_OPERATION     = 0x0010,
62         SET_NOTIFICATION  = 0x0100,
63 };
64
65 struct xmlSupported {
66         int mode;
67 };
68
69 struct xmlOperation {
70         char *name;
71         char *oper;
72         bool background;
73 };
74
75 struct xmlConfiguration {
76         char *name;
77         char *path;
78         char *value;
79 };
80
81 /* XML */
82 int make_empty_configuration_list(void);
83 int make_configuration_list(int usb_mode);
84 void release_configuration_list(void);
85 int make_supported_confs_list(void);
86 void release_supported_confs_list(void);
87 int make_operation_list(int usb_mode, char *action);
88 void release_operations_list(void);
89
90 int get_operations_list(dd_list **list);
91 int get_configurations_list(dd_list **list);
92
93 /* vconf callbacks */
94 void client_mode_changed(keynode_t* key, void *data);
95 void prev_client_mode_changed(keynode_t* key, void *data);
96 void debug_mode_changed(keynode_t* key, void *data);
97 void tethering_status_changed(keynode_t* key, void *data);
98
99 /* Check usb state */
100 int get_default_mode(void);
101 int check_current_usb_state(void);
102 int get_current_usb_mode(void);
103 int get_selected_usb_mode(void);
104 int get_debug_mode(void);
105 int change_selected_usb_mode(int mode);
106 int update_current_usb_mode(int mode);
107 int update_usb_state(int state);
108
109 /* Unset usb mode */
110 void unset_client_mode(int mode, bool change);
111
112 /* USB control */
113 int control_start(void);
114 int control_stop(void);
115 int control_status(void);
116 void wait_until_booting_done(void);
117 void usbclient_init_booting_done(void);
118 void act_usb_connected(void);
119
120 /* USB syspopup */
121 void launch_syspopup(char *str);
122
123 /* Change usb mode */
124 void change_client_setting(int options);
125 bool get_wait_configured(void);
126
127 #endif /* __USB_CLIENT_H__ */