Lines Matching refs:dev
33 const struct device *dev; member
49 static void gnss_emul_lock_sem(const struct device *dev) in gnss_emul_lock_sem() argument
51 struct gnss_emul_data *data = dev->data; in gnss_emul_lock_sem()
56 static void gnss_emul_unlock_sem(const struct device *dev) in gnss_emul_unlock_sem() argument
58 struct gnss_emul_data *data = dev->data; in gnss_emul_unlock_sem()
63 static void gnss_emul_update_fix_timestamp(const struct device *dev, bool resuming) in gnss_emul_update_fix_timestamp() argument
65 struct gnss_emul_data *data = dev->data; in gnss_emul_update_fix_timestamp()
76 static bool gnss_emul_fix_is_acquired(const struct device *dev) in gnss_emul_fix_is_acquired() argument
78 struct gnss_emul_data *data = dev->data; in gnss_emul_fix_is_acquired()
86 static void gnss_emul_clear_fix_timestamp(const struct device *dev) in gnss_emul_clear_fix_timestamp() argument
88 struct gnss_emul_data *data = dev->data; in gnss_emul_clear_fix_timestamp()
94 static void gnss_emul_schedule_work(const struct device *dev) in gnss_emul_schedule_work() argument
96 struct gnss_emul_data *data = dev->data; in gnss_emul_schedule_work()
101 static bool gnss_emul_cancel_work(const struct device *dev) in gnss_emul_cancel_work() argument
103 struct gnss_emul_data *data = dev->data; in gnss_emul_cancel_work()
109 static bool gnss_emul_is_resumed(const struct device *dev) in gnss_emul_is_resumed() argument
111 struct gnss_emul_data *data = dev->data; in gnss_emul_is_resumed()
116 static void gnss_emul_lock(const struct device *dev) in gnss_emul_lock() argument
118 gnss_emul_lock_sem(dev); in gnss_emul_lock()
119 gnss_emul_cancel_work(dev); in gnss_emul_lock()
122 static void gnss_emul_unlock(const struct device *dev) in gnss_emul_unlock() argument
124 if (gnss_emul_is_resumed(dev)) { in gnss_emul_unlock()
125 gnss_emul_schedule_work(dev); in gnss_emul_unlock()
128 gnss_emul_unlock_sem(dev); in gnss_emul_unlock()
131 static int gnss_emul_set_fix_rate(const struct device *dev, uint32_t fix_interval_ms) in gnss_emul_set_fix_rate() argument
133 struct gnss_emul_data *data = dev->data; in gnss_emul_set_fix_rate()
143 static int gnss_emul_get_fix_rate(const struct device *dev, uint32_t *fix_interval_ms) in gnss_emul_get_fix_rate() argument
145 struct gnss_emul_data *data = dev->data; in gnss_emul_get_fix_rate()
151 static int gnss_emul_set_navigation_mode(const struct device *dev, in gnss_emul_set_navigation_mode() argument
154 struct gnss_emul_data *data = dev->data; in gnss_emul_set_navigation_mode()
164 static int gnss_emul_get_navigation_mode(const struct device *dev, in gnss_emul_get_navigation_mode() argument
167 struct gnss_emul_data *data = dev->data; in gnss_emul_get_navigation_mode()
173 static int gnss_emul_set_enabled_systems(const struct device *dev, gnss_systems_t systems) in gnss_emul_set_enabled_systems() argument
175 struct gnss_emul_data *data = dev->data; in gnss_emul_set_enabled_systems()
185 static int gnss_emul_get_enabled_systems(const struct device *dev, gnss_systems_t *systems) in gnss_emul_get_enabled_systems() argument
187 struct gnss_emul_data *data = dev->data; in gnss_emul_get_enabled_systems()
194 static void gnss_emul_resume(const struct device *dev) in gnss_emul_resume() argument
196 gnss_emul_update_fix_timestamp(dev, true); in gnss_emul_resume()
199 static void gnss_emul_suspend(const struct device *dev) in gnss_emul_suspend() argument
201 gnss_emul_clear_fix_timestamp(dev); in gnss_emul_suspend()
204 static int gnss_emul_pm_action(const struct device *dev, enum pm_device_action action) in gnss_emul_pm_action() argument
208 gnss_emul_lock(dev); in gnss_emul_pm_action()
212 gnss_emul_suspend(dev); in gnss_emul_pm_action()
216 gnss_emul_resume(dev); in gnss_emul_pm_action()
224 gnss_emul_unlock(dev); in gnss_emul_pm_action()
229 static int gnss_emul_api_set_fix_rate(const struct device *dev, uint32_t fix_interval_ms) in gnss_emul_api_set_fix_rate() argument
233 gnss_emul_lock(dev); in gnss_emul_api_set_fix_rate()
235 if (!gnss_emul_is_resumed(dev)) { in gnss_emul_api_set_fix_rate()
239 ret = gnss_emul_set_fix_rate(dev, fix_interval_ms); in gnss_emul_api_set_fix_rate()
242 gnss_emul_unlock(dev); in gnss_emul_api_set_fix_rate()
246 static int gnss_emul_api_get_fix_rate(const struct device *dev, uint32_t *fix_interval_ms) in gnss_emul_api_get_fix_rate() argument
250 gnss_emul_lock(dev); in gnss_emul_api_get_fix_rate()
252 if (!gnss_emul_is_resumed(dev)) { in gnss_emul_api_get_fix_rate()
256 ret = gnss_emul_get_fix_rate(dev, fix_interval_ms); in gnss_emul_api_get_fix_rate()
259 gnss_emul_unlock(dev); in gnss_emul_api_get_fix_rate()
263 static int gnss_emul_api_set_navigation_mode(const struct device *dev, in gnss_emul_api_set_navigation_mode() argument
268 gnss_emul_lock(dev); in gnss_emul_api_set_navigation_mode()
270 if (!gnss_emul_is_resumed(dev)) { in gnss_emul_api_set_navigation_mode()
274 ret = gnss_emul_set_navigation_mode(dev, mode); in gnss_emul_api_set_navigation_mode()
277 gnss_emul_unlock(dev); in gnss_emul_api_set_navigation_mode()
281 static int gnss_emul_api_get_navigation_mode(const struct device *dev, in gnss_emul_api_get_navigation_mode() argument
286 gnss_emul_lock(dev); in gnss_emul_api_get_navigation_mode()
288 if (!gnss_emul_is_resumed(dev)) { in gnss_emul_api_get_navigation_mode()
292 ret = gnss_emul_get_navigation_mode(dev, mode); in gnss_emul_api_get_navigation_mode()
295 gnss_emul_unlock(dev); in gnss_emul_api_get_navigation_mode()
299 static int gnss_emul_api_set_enabled_systems(const struct device *dev, gnss_systems_t systems) in gnss_emul_api_set_enabled_systems() argument
303 gnss_emul_lock(dev); in gnss_emul_api_set_enabled_systems()
305 if (!gnss_emul_is_resumed(dev)) { in gnss_emul_api_set_enabled_systems()
309 ret = gnss_emul_set_enabled_systems(dev, systems); in gnss_emul_api_set_enabled_systems()
312 gnss_emul_unlock(dev); in gnss_emul_api_set_enabled_systems()
316 static int gnss_emul_api_get_enabled_systems(const struct device *dev, gnss_systems_t *systems) in gnss_emul_api_get_enabled_systems() argument
320 gnss_emul_lock(dev); in gnss_emul_api_get_enabled_systems()
322 if (!gnss_emul_is_resumed(dev)) { in gnss_emul_api_get_enabled_systems()
326 ret = gnss_emul_get_enabled_systems(dev, systems); in gnss_emul_api_get_enabled_systems()
329 gnss_emul_unlock(dev); in gnss_emul_api_get_enabled_systems()
333 static int gnss_emul_api_get_supported_systems(const struct device *dev, gnss_systems_t *systems) in gnss_emul_api_get_supported_systems() argument
349 static void gnss_emul_clear_data(const struct device *dev) in gnss_emul_clear_data() argument
351 struct gnss_emul_data *data = dev->data; in gnss_emul_clear_data()
356 static void gnss_emul_set_fix(const struct device *dev) in gnss_emul_set_fix() argument
358 struct gnss_emul_data *data = dev->data; in gnss_emul_set_fix()
366 static void gnss_emul_set_utc(const struct device *dev) in gnss_emul_set_utc() argument
368 struct gnss_emul_data *data = dev->data; in gnss_emul_set_utc()
386 static void gnss_emul_set_nav_data(const struct device *dev) in gnss_emul_set_nav_data() argument
388 struct gnss_emul_data *data = dev->data; in gnss_emul_set_nav_data()
398 static void gnss_emul_clear_satellites(const struct device *dev) in gnss_emul_clear_satellites() argument
400 struct gnss_emul_data *data = dev->data; in gnss_emul_clear_satellites()
405 static bool gnss_emul_system_enabled(const struct device *dev, uint8_t system_bit) in gnss_emul_system_enabled() argument
407 struct gnss_emul_data *data = dev->data; in gnss_emul_system_enabled()
412 static void gnss_emul_add_satellite(const struct device *dev, uint8_t system_bit) in gnss_emul_add_satellite() argument
414 struct gnss_emul_data *data = dev->data; in gnss_emul_add_satellite()
426 static void gnss_emul_set_satellites(const struct device *dev) in gnss_emul_set_satellites() argument
428 gnss_emul_clear_satellites(dev); in gnss_emul_set_satellites()
431 if (!gnss_emul_system_enabled(dev, i)) { in gnss_emul_set_satellites()
435 gnss_emul_add_satellite(dev, i); in gnss_emul_set_satellites()
444 const struct device *dev = data->dev; in gnss_emul_work_handler() local
446 if (!gnss_emul_fix_is_acquired(dev)) { in gnss_emul_work_handler()
447 gnss_emul_clear_data(dev); in gnss_emul_work_handler()
449 gnss_emul_set_fix(dev); in gnss_emul_work_handler()
450 gnss_emul_set_utc(dev); in gnss_emul_work_handler()
451 gnss_emul_set_nav_data(dev); in gnss_emul_work_handler()
454 gnss_publish_data(dev, &data->data); in gnss_emul_work_handler()
457 gnss_emul_set_satellites(dev); in gnss_emul_work_handler()
458 gnss_publish_satellites(dev, data->satellites, data->satellites_len); in gnss_emul_work_handler()
461 gnss_emul_update_fix_timestamp(dev, false); in gnss_emul_work_handler()
462 gnss_emul_schedule_work(dev); in gnss_emul_work_handler()
465 static void gnss_emul_init_data(const struct device *dev) in gnss_emul_init_data() argument
467 struct gnss_emul_data *data = dev->data; in gnss_emul_init_data()
469 data->dev = dev; in gnss_emul_init_data()
474 static int gnss_emul_init(const struct device *dev) in gnss_emul_init() argument
476 gnss_emul_init_data(dev); in gnss_emul_init()
478 if (pm_device_is_powered(dev)) { in gnss_emul_init()
479 gnss_emul_update_fix_timestamp(dev, true); in gnss_emul_init()
480 gnss_emul_schedule_work(dev); in gnss_emul_init()
482 pm_device_init_off(dev); in gnss_emul_init()
485 return pm_device_runtime_enable(dev); in gnss_emul_init()