diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2018-07-20 23:08:09 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2018-07-20 23:08:09 +0200 |
commit | 18b52c2983a1b3409011f72d27f15de576c5eb1c (patch) | |
tree | dfd916e4edf86c741abde12f8f632ebee7d93c47 /src/camera/CameraTable.vala | |
parent | ab841afa5cb39058d9ab2cebb67cfe6369443f6e (diff) |
New upstream version 0.28.4upstream/0.28.4
Diffstat (limited to 'src/camera/CameraTable.vala')
-rw-r--r-- | src/camera/CameraTable.vala | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/src/camera/CameraTable.vala b/src/camera/CameraTable.vala index 1636816..3df4ad6 100644 --- a/src/camera/CameraTable.vala +++ b/src/camera/CameraTable.vala @@ -108,100 +108,6 @@ public class CameraTable { do_op(abilities_list.load(null_context), "load camera abilities list"); } - private string[] get_all_usb_cameras() { - string[] cameras = new string[0]; - - GLib.List<GUdev.Device> device_list = client.query_by_subsystem(null); - foreach (GUdev.Device device in device_list) { - string device_file = device.get_device_file(); - if( - // only keep devices that have a non-null device file and that - // have both the ID_GPHOTO2 and GPHOTO2_DRIVER properties set - (device_file != null) && - (device.has_property("ID_GPHOTO2")) && - (device.has_property("GPHOTO2_DRIVER")) - ) { - int camera_bus, camera_device; - // extract the bus and device IDs from the device file string - // TODO: is it safe to parse the absolute path or should we be - // smarter and use a regex to only pick up the end of the path? - if (device_file.scanf("/dev/bus/usb/%d/%d", out camera_bus, out camera_device) < 2) { - critical("get_all_usb_cameras: Failed to scanf device file %s", device_file); - - continue; - } - string camera = "usb:%.3d,%.3d".printf(camera_bus, camera_device); - debug("USB camera detected at %s", camera); - cameras += camera; - } - } - - return cameras; - } - - // USB (or libusb) is a funny beast; if only one USB device is present (i.e. the camera), - // then a single camera is detected at port usb:. However, if multiple USB devices are - // present (including non-cameras), then the first attached camera will be listed twice, - // first at usb:, then at usb:xxx,yyy. If the usb: device is removed, another usb:xxx,yyy - // device will lose its full-path name and be referred to as usb: only. - // - // This function gleans the full port name of a particular port, even if it's the unadorned - // "usb:", by using GUdev. - private bool usb_esp(int current_camera_count, string[] usb_cameras, string port, - out string full_port) { - // sanity - assert(current_camera_count > 0); - - debug("USB ESP: current_camera_count=%d port=%s", current_camera_count, port); - - full_port = null; - - // if GPhoto detects one camera, and USB reports one camera, all is swell - if (current_camera_count == 1 && usb_cameras.length == 1) { - full_port = usb_cameras[0]; - - debug("USB ESP: port=%s full_port=%s", port, full_port); - - return true; - } - - // with more than one camera, skip the mirrored "usb:" port - if (port == "usb:") { - debug("USB ESP: Skipping %s", port); - - return false; - } - - // parse out the bus and device ID - int bus, device; - if (port.scanf("usb:%d,%d", out bus, out device) < 2) { - critical("USB ESP: Failed to scanf %s", port); - - return false; - } - - foreach (string usb_camera in usb_cameras) { - int camera_bus, camera_device; - if (usb_camera.scanf("usb:%d,%d", out camera_bus, out camera_device) < 2) { - critical("USB ESP: Failed to scanf %s", usb_camera); - - continue; - } - - if ((bus == camera_bus) && (device == camera_device)) { - full_port = port; - - debug("USB ESP: port=%s full_port=%s", port, full_port); - - return true; - } - } - - debug("USB ESP: No matching bus/device found for port=%s", port); - - return false; - } - public static string get_port_uri(string port) { return "gphoto2://[%s]/".printf(port); } @@ -242,9 +148,6 @@ public class CameraTable { Gee.HashMap<string, string> detected_map = new Gee.HashMap<string, string>(); - // walk the USB chain and find all PTP cameras; this is necessary for usb_esp - string[] usb_cameras = get_all_usb_cameras(); - // go through the detected camera list and glean their ports for (int ctr = 0; ctr < camera_list.count(); ctr++) { string name; @@ -255,14 +158,6 @@ public class CameraTable { debug("Detected %d/%d %s @ %s", ctr + 1, camera_list.count(), name, port); - // do some USB ESP, skipping ports that cannot be deduced - if (port.has_prefix("usb:")) { - string full_port; - if (!usb_esp(camera_list.count(), usb_cameras, port, out full_port)) - continue; - - port = full_port; - } detected_map.set(port, name); } |