efl

Форк
0
/
ecore_drm.c 
184 строки · 5.0 Кб
1
/* Portions of this code have been derived from Weston
2
 *
3
 * Copyright © 2008-2012 Kristian Høgsberg
4
 * Copyright © 2010-2012 Intel Corporation
5
 * Copyright © 2010-2011 Benjamin Franzke
6
 * Copyright © 2011-2012 Collabora, Ltd.
7
 * Copyright © 2010 Red Hat <mjg@redhat.com>
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a
10
 * copy of this software and associated documentation files (the "Software"),
11
 * to deal in the Software without restriction, including without limitation
12
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13
 * and/or sell copies of the Software, and to permit persons to whom the
14
 * Software is furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice (including the next
17
 * paragraph) shall be included in all copies or substantial portions of the
18
 * Software.
19
 *
20
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26
 * DEALINGS IN THE SOFTWARE.
27
 */
28

29
#include "ecore_drm_private.h"
30

31
/* local variables */
32
static int _ecore_drm_init_count = 0;
33

34
/* external variables */
35
int _ecore_drm_log_dom = -1;
36

37
EAPI int ECORE_DRM_EVENT_ACTIVATE = 0;
38

39
static void
40
_ecore_drm_event_activate_free(void *data EINA_UNUSED, void *event)
41
{
42
   free(event);
43
}
44

45
void
46
_ecore_drm_event_activate_send(Eina_Bool active)
47
{
48
   Ecore_Drm_Event_Activate *e;
49

50
   if (!(e = calloc(1, sizeof(Ecore_Drm_Event_Activate)))) return;
51

52
   e->active = active;
53
   ecore_event_add(ECORE_DRM_EVENT_ACTIVATE, e,
54
                   _ecore_drm_event_activate_free, NULL);
55
}
56

57
/**
58
 * @defgroup Ecore_Drm_Init_Group Drm Library Init and Shutdown Functions
59
 *
60
 * Functions that start and shutdown the Ecore_Drm Library.
61
 */
62

63
/**
64
 * Initialize the Ecore_Drm library
65
 *
66
 * @return  The number of times the library has been initialized without
67
 *          being shut down. 0 is returned if an error occurs.
68
 *
69
 * @ingroup Ecore_Drm_Init_Group
70
 */
71
EAPI int
72
ecore_drm_init(void)
73
{
74
   /* if we have already initialized, return the count */
75
   if (++_ecore_drm_init_count != 1) return _ecore_drm_init_count;
76

77
   /* try to init eina */
78
   if (!eina_init()) return --_ecore_drm_init_count;
79

80
   /* try to init ecore */
81
   if (!ecore_init())
82
     {
83
        eina_shutdown();
84
        return --_ecore_drm_init_count;
85
     }
86

87
   /* try to init ecore_event */
88
   if (!ecore_event_init())
89
     {
90
        ecore_shutdown();
91
        eina_shutdown();
92
        return --_ecore_drm_init_count;
93
     }
94

95
   /* set logging level */
96
   /* eina_log_level_set(EINA_LOG_LEVEL_DBG); */
97

98
   /* try to create logging domain */
99
   _ecore_drm_log_dom =
100
     eina_log_domain_register("ecore_drm", ECORE_DRM_DEFAULT_LOG_COLOR);
101
   if (!_ecore_drm_log_dom)
102
     {
103
        EINA_LOG_ERR("Could not create log domain for Ecore_Drm");
104
        goto log_err;
105
     }
106

107
   /* try to init eeze */
108
   if (!eeze_init()) goto eeze_err;
109

110
   _ecore_drm_inputs_init();
111

112
   ECORE_DRM_EVENT_ACTIVATE = ecore_event_type_new();
113
   ECORE_DRM_EVENT_OUTPUT = ecore_event_type_new();
114
   ECORE_DRM_EVENT_SEAT_ADD = ecore_event_type_new();
115

116
   /* return init count */
117
   return _ecore_drm_init_count;
118

119
eeze_err:
120
   eina_log_domain_unregister(_ecore_drm_log_dom);
121
   _ecore_drm_log_dom = -1;
122
log_err:
123
   ecore_event_shutdown();
124
   ecore_shutdown();
125
   eina_shutdown();
126
   return --_ecore_drm_init_count;
127
}
128

129
/**
130
 * Shutdown the Ecore_Drm library.
131
 *
132
 * @return  The number of times the library has been initialized without
133
 *          being shutdown. 0 is returned if an error occurs.
134
 *
135
 * @ingroup Ecore_Drm_Init_Group
136
 */
137
EAPI int
138
ecore_drm_shutdown(void)
139
{
140
   Eina_List *lists;
141
   Ecore_Drm_Device *dev;
142

143
   /* _ecore_drm_init_count should not go below zero. */
144
   if (_ecore_drm_init_count < 1)
145
     {
146
        ERR("Ecore_Drm Shutdown called without Ecore_Drm Init");
147
        return 0;
148
     }
149

150
   /* if we are still in use, decrement init count and get out */
151
   if (--_ecore_drm_init_count != 0) return _ecore_drm_init_count;
152

153
   ecore_event_type_flush(ECORE_DRM_EVENT_ACTIVATE,
154
                          ECORE_DRM_EVENT_OUTPUT,
155
                          ECORE_DRM_EVENT_SEAT_ADD);
156

157
   /* free the list of devices */
158
   lists = eina_list_clone(ecore_drm_devices_get());
159
   EINA_LIST_FREE(lists, dev)
160
     {
161
        ecore_drm_device_free(dev);
162
     }
163

164
   _ecore_drm_inputs_shutdown();
165

166
   /* close eeze */
167
   eeze_shutdown();
168

169
   /* shutdown ecore_event */
170
   ecore_event_shutdown();
171

172
   /* shutdown ecore */
173
   ecore_shutdown();
174

175
   /* unregsiter log domain */
176
   eina_log_domain_unregister(_ecore_drm_log_dom);
177
   _ecore_drm_log_dom = -1;
178

179
   /* shutdown eina */
180
   eina_shutdown();
181

182
   /* return init count */
183
   return _ecore_drm_init_count;
184
}
185

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.