Skip to content

Latest commit

 

History

History
193 lines (164 loc) · 5.22 KB

camera.c

File metadata and controls

193 lines (164 loc) · 5.22 KB
 
Dec 16, 2010
Dec 16, 2010
1
2
3
4
/**
* @file camera.c
* Camera module -- this handles the camera LED-indicator for MCE
* <p>
May 12, 2011
May 12, 2011
5
* Copyright © 2007-2011 Nokia Corporation and/or its subsidiary(-ies).
May 17, 2019
May 17, 2019
6
* Copyright (C) 2013-2019 Jolla Ltd.
Dec 16, 2010
Dec 16, 2010
7
8
* <p>
* @author David Weinehall <david.weinehall@nokia.com>
May 17, 2019
May 17, 2019
9
10
* @author Santtu Lakkala <ext-santtu.1.lakkala@nokia.com>
* @author Simo Piiroinen <simo.piiroinen@jollamobile.com>
Dec 16, 2010
Dec 16, 2010
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
*
* mce is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* mce 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mce. If not, see <http://www.gnu.org/licenses/>.
*/
#include "camera.h"
Mar 15, 2018
Mar 15, 2018
27
#include "../mce-log.h"
May 26, 2014
May 26, 2014
28
29
#include "../mce-io.h"
#include "../mce-conf.h"
Mar 13, 2015
Mar 13, 2015
30
#include "../tklock.h"
May 27, 2014
May 27, 2014
31
32
33
34
#include <string.h>
#include <gmodule.h>
Dec 16, 2010
Dec 16, 2010
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/** Unlock the tklock if the camera is popped out? */
static gboolean popout_unlock = DEFAULT_CAMERA_POPOUT_UNLOCK;
/** Module name */
#define MODULE_NAME "camera"
/** Functionality provided by this module */
static const gchar *const provides[] = { MODULE_NAME, NULL };
/** Functionality that this module depends on */
static const gchar *const depends[] = { "tklock", NULL };
/** Functionality that this module recommends */
static const gchar *const recommends[] = { "led", NULL };
/** Module information */
G_MODULE_EXPORT module_info_struct module_info = {
/** Name of the module */
.name = MODULE_NAME,
/** Module dependencies */
.depends = depends,
/** Module recommends */
.recommends = recommends,
/** Module provides */
.provides = provides,
/** Module priority */
.priority = 250
};
/** ID for the camera active state I/O monitor */
Dec 23, 2014
Dec 23, 2014
66
static mce_io_mon_t *camera_active_state_iomon_id = NULL;
Dec 16, 2010
Dec 16, 2010
67
68
/** ID for the camera pop-out state I/O monitor */
Dec 23, 2014
Dec 23, 2014
69
static mce_io_mon_t *camera_popout_state_iomon_id = NULL;
Dec 16, 2010
Dec 16, 2010
70
Mar 14, 2014
Mar 14, 2014
71
72
73
74
/** Camera pop-out state I/O monitor deleted callback
*
* @param iomon io monitor that is about to get deleted
*/
Dec 23, 2014
Dec 23, 2014
75
static void camera_popout_state_iomon_delete_cb(mce_io_mon_t *iomon)
Mar 14, 2014
Mar 14, 2014
76
77
78
79
80
81
82
83
84
{
if( iomon == camera_popout_state_iomon_id )
camera_popout_state_iomon_id = 0;
}
/** Camera active state I/O monitor deleted callback
*
* @param iomon io monitor that is about to get deleted
*/
Dec 23, 2014
Dec 23, 2014
85
static void camera_active_state_iomon_delete_cb(mce_io_mon_t *iomon)
Mar 14, 2014
Mar 14, 2014
86
87
88
89
90
{
if( iomon == camera_active_state_iomon_id )
camera_active_state_iomon_id = 0;
}
Dec 16, 2010
Dec 16, 2010
91
92
93
94
95
/**
* I/O monitor callback for the camera active state
*
* @param data The new data
* @param bytes_read Unused
May 12, 2011
May 12, 2011
96
* @return Always returns FALSE to return remaining chunks (if any)
Dec 16, 2010
Dec 16, 2010
97
*/
Jan 7, 2016
Jan 7, 2016
98
static gboolean camera_active_state_iomon_input_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
Dec 16, 2010
Dec 16, 2010
99
{
Jan 7, 2016
Jan 7, 2016
100
(void)iomon;
Dec 16, 2010
Dec 16, 2010
101
102
103
(void)bytes_read;
if (!strncmp(data, MCE_CAMERA_ACTIVE, strlen(MCE_CAMERA_ACTIVE))) {
Sep 19, 2018
Sep 19, 2018
104
105
datapipe_exec_full(&led_pattern_activate_pipe,
MCE_LED_PATTERN_CAMERA);
Dec 16, 2010
Dec 16, 2010
106
} else {
Sep 19, 2018
Sep 19, 2018
107
108
datapipe_exec_full(&led_pattern_deactivate_pipe,
MCE_LED_PATTERN_CAMERA);
Dec 16, 2010
Dec 16, 2010
109
}
May 12, 2011
May 12, 2011
110
111
return FALSE;
Dec 16, 2010
Dec 16, 2010
112
113
114
115
116
117
118
}
/**
* I/O monitor callback for the camera pop-out state
*
* @param data The new data
* @param bytes_read Unused
May 12, 2011
May 12, 2011
119
* @return Always returns FALSE to return remaining chunks (if any)
Dec 16, 2010
Dec 16, 2010
120
*/
Jan 7, 2016
Jan 7, 2016
121
static gboolean camera_popout_state_iomon_input_cb(mce_io_mon_t *iomon, gpointer data, gsize bytes_read)
Dec 16, 2010
Dec 16, 2010
122
{
Jan 7, 2016
Jan 7, 2016
123
(void)iomon;
Dec 16, 2010
Dec 16, 2010
124
125
126
(void)bytes_read;
/* Generate activity */
Nov 20, 2018
Nov 20, 2018
127
mce_datapipe_generate_activity();
Dec 16, 2010
Dec 16, 2010
128
129
130
131
132
133
134
135
if (popout_unlock == FALSE)
goto EXIT;
/* Unlock tklock if camera is popped out */
if (!strncmp(data, MCE_CAMERA_POPPED_OUT,
strlen(MCE_CAMERA_POPPED_OUT))) {
/* Request delayed unlock of touchscreen/keypad lock */
Mar 15, 2018
Mar 15, 2018
136
mce_datapipe_request_tklock(TKLOCK_REQUEST_OFF_DELAYED);
Dec 16, 2010
Dec 16, 2010
137
138
139
}
EXIT:
May 12, 2011
May 12, 2011
140
return FALSE;
Dec 16, 2010
Dec 16, 2010
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
}
/**
* Init function for the camera module
*
* @todo XXX status needs to be set on error!
*
* @param module Unused
* @return NULL on success, a string with an error message on failure
*/
G_MODULE_EXPORT const gchar *g_module_check_init(GModule *module);
const gchar *g_module_check_init(GModule *module)
{
(void)module;
/* Get configuration options */
popout_unlock = mce_conf_get_bool(MCE_CONF_TKLOCK_GROUP,
MCE_CONF_CAMERA_POPOUT_UNLOCK,
Mar 25, 2013
Mar 25, 2013
159
DEFAULT_CAMERA_POPOUT_UNLOCK);
Dec 16, 2010
Dec 16, 2010
160
161
162
/* Register I/O monitors */
camera_active_state_iomon_id =
Dec 23, 2014
Dec 23, 2014
163
164
165
166
167
mce_io_mon_register_string(-1, CAMERA_ACTIVE_STATE_PATH,
MCE_IO_ERROR_POLICY_IGNORE,
TRUE,
camera_active_state_iomon_input_cb,
camera_active_state_iomon_delete_cb);
Dec 16, 2010
Dec 16, 2010
168
169
camera_popout_state_iomon_id =
Dec 23, 2014
Dec 23, 2014
170
171
172
173
174
mce_io_mon_register_string(-1, CAMERA_POPOUT_STATE_PATH,
MCE_IO_ERROR_POLICY_IGNORE,
TRUE,
camera_popout_state_iomon_input_cb,
camera_popout_state_iomon_delete_cb);
Dec 16, 2010
Dec 16, 2010
175
176
177
178
179
180
181
182
183
184
185
186
187
188
return NULL;
}
/**
* Exit function for the camera module
*
* @param module Unused
*/
G_MODULE_EXPORT void g_module_unload(GModule *module);
void g_module_unload(GModule *module)
{
(void)module;
/* Unregister I/O monitors */
Dec 23, 2014
Dec 23, 2014
189
190
mce_io_mon_unregister(camera_popout_state_iomon_id);
mce_io_mon_unregister(camera_active_state_iomon_id);
Dec 16, 2010
Dec 16, 2010
191
192
193
return;
}