diff options
-rw-r--r-- | include/libcamera/internal/ipa_data_serializer.h | 1 | ||||
-rw-r--r-- | src/apps/cam/drm.cpp | 25 | ||||
-rw-r--r-- | src/ipa/rpi/common/ipa_base.cpp | 3 | ||||
-rw-r--r-- | src/libcamera/ipa_data_serializer.cpp | 1 | ||||
-rw-r--r-- | src/libcamera/pipeline/mali-c55/mali-c55.cpp | 9 | ||||
-rw-r--r-- | src/libcamera/process.cpp | 18 |
6 files changed, 36 insertions, 21 deletions
diff --git a/include/libcamera/internal/ipa_data_serializer.h b/include/libcamera/internal/ipa_data_serializer.h index b4614f21..b1fefba5 100644 --- a/include/libcamera/internal/ipa_data_serializer.h +++ b/include/libcamera/internal/ipa_data_serializer.h @@ -309,7 +309,6 @@ public: serialize(const Flags<E> &data, [[maybe_unused]] ControlSerializer *cs = nullptr) { std::vector<uint8_t> dataVec; - dataVec.reserve(sizeof(Flags<E>)); appendPOD<uint32_t>(dataVec, static_cast<typename Flags<E>::Type>(data)); return { dataVec, {} }; diff --git a/src/apps/cam/drm.cpp b/src/apps/cam/drm.cpp index 47bbb6b0..f4b47097 100644 --- a/src/apps/cam/drm.cpp +++ b/src/apps/cam/drm.cpp @@ -450,8 +450,6 @@ int Device::openCard() } for (struct dirent *res; (res = readdir(folder));) { - uint64_t cap; - if (strncmp(res->d_name, "card", 4)) continue; @@ -465,15 +463,22 @@ int Device::openCard() } /* - * Skip devices that don't support the modeset API, to avoid - * selecting a DRM device corresponding to a GPU. There is no - * modeset capability, but the kernel returns an error for most - * caps if mode setting isn't support by the driver. The - * DRM_CAP_DUMB_BUFFER capability is one of those, other would - * do as well. The capability value itself isn't relevant. + * Skip non-display devices. While this could in theory be done + * by checking for support of the mode setting API, some + * out-of-tree render-only GPU drivers (namely powervr) + * incorrectly set the DRIVER_MODESET driver feature. Check for + * the presence of at least one CRTC, encoder and connector + * instead. */ - ret = drmGetCap(fd_, DRM_CAP_DUMB_BUFFER, &cap); - if (ret < 0) { + std::unique_ptr<drmModeRes, decltype(&drmModeFreeResources)> resources{ + drmModeGetResources(fd_), + &drmModeFreeResources + }; + if (!resources || + resources->count_connectors <= 0 || + resources->count_crtcs <= 0 || + resources->count_encoders <= 0) { + resources.reset(); drmClose(fd_); fd_ = -1; continue; diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index e0a93daa..e0f8b7e7 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -1563,7 +1563,8 @@ void IpaBase::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDu RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( controller_.getAlgorithm("agc")); - agc->setMaxExposureTime(maxExposureTime); + if (agc) + agc->setMaxExposureTime(maxExposureTime); } void IpaBase::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) diff --git a/src/libcamera/ipa_data_serializer.cpp b/src/libcamera/ipa_data_serializer.cpp index 2189a246..0537f785 100644 --- a/src/libcamera/ipa_data_serializer.cpp +++ b/src/libcamera/ipa_data_serializer.cpp @@ -196,7 +196,6 @@ IPADataSerializer<type>::serialize(const type &data, \ [[maybe_unused]] ControlSerializer *cs) \ { \ std::vector<uint8_t> dataVec; \ - dataVec.reserve(sizeof(type)); \ appendPOD<type>(dataVec, data); \ \ return { dataVec, {} }; \ diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index a05e11fc..f5260f5f 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -131,8 +131,6 @@ private: void setSensorControls(const ControlList &sensorControls); std::string id_; - std::vector<unsigned int> tpgCodes_; - std::vector<Size> tpgSizes_; Size tpgResolution_; }; @@ -180,16 +178,15 @@ void MaliC55CameraData::initTPGData() if (formats.empty()) return; - tpgCodes_ = utils::map_keys(formats); - std::sort(tpgCodes_.begin(), tpgCodes_.end()); + std::vector<Size> tpgSizes; for (const auto &format : formats) { const std::vector<SizeRange> &ranges = format.second; - std::transform(ranges.begin(), ranges.end(), std::back_inserter(tpgSizes_), + std::transform(ranges.begin(), ranges.end(), std::back_inserter(tpgSizes), [](const SizeRange &range) { return range.max; }); } - tpgResolution_ = tpgSizes_.back(); + tpgResolution_ = tpgSizes.back(); } void MaliC55CameraData::setSensorControls(const ControlList &sensorControls) diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index 68fad327..d836fb07 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -259,7 +259,21 @@ int Process::start(const std::string &path, if (isolate()) _exit(EXIT_FAILURE); - closeAllFdsExcept(fds); + std::vector<int> v(fds); + v.push_back(STDERR_FILENO); + closeAllFdsExcept(v); + + const auto tryDevNullLowestFd = [](int expected, int oflag) { + int fd = open("/dev/null", oflag); + if (fd < 0) + _exit(EXIT_FAILURE); + if (fd != expected) + close(fd); + }; + + tryDevNullLowestFd(STDIN_FILENO, O_RDONLY); + tryDevNullLowestFd(STDOUT_FILENO, O_WRONLY); + tryDevNullLowestFd(STDERR_FILENO, O_WRONLY); const char *file = utils::secure_getenv("LIBCAMERA_LOG_FILE"); if (file && strcmp(file, "syslog")) @@ -274,7 +288,7 @@ int Process::start(const std::string &path, execv(path.c_str(), (char **)argv); - exit(EXIT_FAILURE); + _exit(EXIT_FAILURE); } } |