Lines Matching refs:sd
42 static int session_device_notify(SessionDevice *sd, enum SessionDeviceNotifications type) {
49 assert(sd);
51 major = major(sd->dev);
52 minor = minor(sd->dev);
54 if (!sd->session->controller)
57 path = session_bus_path(sd->session);
62 sd->session->manager->bus,
69 r = sd_bus_message_set_destination(m, sd->session->controller);
75 r = sd_bus_message_append(m, "uuh", major, minor, sd->fd);
98 return sd_bus_send(sd->session->manager->bus, m, NULL);
143 static int session_device_open(SessionDevice *sd, bool active) {
146 assert(sd->type != DEVICE_TYPE_UNKNOWN);
149 fd = open(sd->node, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
153 switch (sd->type) {
185 static int session_device_start(SessionDevice *sd) {
188 assert(sd);
189 assert(session_is_active(sd->session));
191 if (sd->active)
194 switch (sd->type) {
199 r = sd_drmsetmaster(sd->fd);
206 r = session_device_open(sd, true);
209 close_nointr(sd->fd);
210 sd->fd = r;
218 sd->active = true;
222 static void session_device_stop(SessionDevice *sd) {
223 assert(sd);
225 if (!sd->active)
228 switch (sd->type) {
234 sd_drmdropmaster(sd->fd);
241 sd_eviocrevoke(sd->fd);
249 sd->active = false;
271 static int session_device_verify(SessionDevice *sd) {
276 dev = udev_device_new_from_devnum(sd->session->manager->udev, 'c', sd->dev);
288 sd->type = detect_device_type(dev);
289 if (sd->type == DEVICE_TYPE_UNKNOWN) {
292 } else if (sd->type == DEVICE_TYPE_EVDEV) {
301 } else if (sd->type != DEVICE_TYPE_DRM) {
310 sd->device = hashmap_get(sd->session->manager->devices, sp);
311 if (!sd->device) {
315 r = manager_process_seat_device(sd->session->manager, dev);
320 sd->device = hashmap_get(sd->session->manager->devices, sp);
321 if (!sd->device) {
327 if (sd->device->seat != sd->session->seat) {
332 sd->node = strdup(node);
333 if (!sd->node) {
345 SessionDevice *sd;
354 sd = new0(SessionDevice, 1);
355 if (!sd)
358 sd->session = s;
359 sd->dev = dev;
360 sd->fd = -1;
361 sd->type = DEVICE_TYPE_UNKNOWN;
363 r = session_device_verify(sd);
367 r = hashmap_put(s->devices, &sd->dev, sd);
377 sd->active = session_is_active(s);
378 r = session_device_open(sd, sd->active);
381 if (sd->active && r == -EINVAL) {
382 sd->active = false;
383 r = session_device_open(sd, false);
388 sd->fd = r;
390 LIST_PREPEND(sd_by_device, sd->device->session_devices, sd);
392 *out = sd;
396 hashmap_remove(s->devices, &sd->dev);
397 free(sd->node);
398 free(sd);
402 void session_device_free(SessionDevice *sd) {
403 assert(sd);
405 session_device_stop(sd);
406 session_device_notify(sd, SESSION_DEVICE_RELEASE);
407 close_nointr(sd->fd);
409 LIST_REMOVE(sd_by_device, sd->device->session_devices, sd);
411 hashmap_remove(sd->session->devices, &sd->dev);
413 free(sd->node);
414 free(sd);
417 void session_device_complete_pause(SessionDevice *sd) {
421 if (!sd->active)
424 session_device_stop(sd);
427 HASHMAP_FOREACH(iter, sd->session->devices, i)
432 seat_complete_switch(sd->session->seat);
436 SessionDevice *sd;
442 HASHMAP_FOREACH(sd, s->devices, i) {
443 if (!sd->active) {
444 r = session_device_start(sd);
446 session_device_notify(sd, SESSION_DEVICE_RESUME);
452 SessionDevice *sd;
457 HASHMAP_FOREACH(sd, s->devices, i) {
458 if (sd->active) {
459 session_device_stop(sd);
460 session_device_notify(sd, SESSION_DEVICE_PAUSE);
466 SessionDevice *sd;
472 HASHMAP_FOREACH(sd, s->devices, i) {
473 if (sd->active) {
474 session_device_notify(sd, SESSION_DEVICE_TRY_PAUSE);