|
@@ -134,6 +134,14 @@ libmegapixels_open(libmegapixels_camera *camera)
|
|
|
log_error("Bridge already opened\n");
|
|
|
return -1;
|
|
|
}
|
|
|
+ if (camera->flash_fd != 0) {
|
|
|
+ log_error("Flash already opened\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ if (camera->lens_fd != 0) {
|
|
|
+ log_error("Lens already opened\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
|
|
|
if (camera->media_path) {
|
|
|
camera->media_fd = open(camera->media_path, O_RDWR);
|
|
@@ -166,6 +174,14 @@ libmegapixels_open(libmegapixels_camera *camera)
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
+ if (camera->lens_path) {
|
|
|
+ camera->lens_fd = open(camera->lens_path, O_RDWR);
|
|
|
+ if (camera->lens_fd < 0) {
|
|
|
+ log_error("Could not open %s: %s\n", camera->lens_path, strerror(errno));
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// If this is an UVC camera the sensor _is_ the video device
|
|
|
if (camera->sensor_fd == 0) {
|
|
|
camera->sensor_fd = camera->video_fd;
|
|
@@ -208,6 +224,10 @@ libmegapixels_close(libmegapixels_camera *camera)
|
|
|
close(camera->flash_fd);
|
|
|
camera->flash_fd = 0;
|
|
|
}
|
|
|
+ if (camera->lens_fd != 0) {
|
|
|
+ close(camera->lens_fd);
|
|
|
+ camera->lens_fd = 0;
|
|
|
+ }
|
|
|
|
|
|
for (int i = 0; i < camera->num_handles; i++) {
|
|
|
if (camera->handles[i]->fd != 0) {
|