utils/udev: drop Ptr alias
It's not very useful and makes it less clear what the type is
This commit is contained in:
parent
74f10d0cdf
commit
f60727c438
3 changed files with 13 additions and 14 deletions
|
@ -144,7 +144,7 @@ bool DrmBackend::initialize()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto devices = m_udev->listGPUs();
|
const auto devices = m_udev->listGPUs();
|
||||||
for (const UdevDevice::Ptr &device : devices) {
|
for (const auto &device : devices) {
|
||||||
if (device->seat() == m_session->seat()) {
|
if (device->seat() == m_session->seat()) {
|
||||||
addGpu(device->devNode());
|
addGpu(device->devNode());
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
};
|
};
|
||||||
void addMatch(Match match, const char *name);
|
void addMatch(Match match, const char *name);
|
||||||
void scan();
|
void scan();
|
||||||
std::vector<UdevDevice::Ptr> find();
|
std::vector<std::unique_ptr<UdevDevice>> find();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Udev *m_udev;
|
Udev *m_udev;
|
||||||
|
@ -92,12 +92,12 @@ void UdevEnumerate::scan()
|
||||||
udev_enumerate_scan_devices(m_enumerate.get());
|
udev_enumerate_scan_devices(m_enumerate.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UdevDevice::Ptr> UdevEnumerate::find()
|
std::vector<std::unique_ptr<UdevDevice>> UdevEnumerate::find()
|
||||||
{
|
{
|
||||||
if (!m_enumerate) {
|
if (!m_enumerate) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
std::vector<UdevDevice::Ptr> vect;
|
std::vector<std::unique_ptr<UdevDevice>> vect;
|
||||||
udev_list_entry *it = udev_enumerate_get_list_entry(m_enumerate.get());
|
udev_list_entry *it = udev_enumerate_get_list_entry(m_enumerate.get());
|
||||||
while (it) {
|
while (it) {
|
||||||
auto current = it;
|
auto current = it;
|
||||||
|
@ -110,13 +110,13 @@ std::vector<UdevDevice::Ptr> UdevEnumerate::find()
|
||||||
return vect;
|
return vect;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UdevDevice::Ptr> Udev::listGPUs()
|
std::vector<std::unique_ptr<UdevDevice>> Udev::listGPUs()
|
||||||
{
|
{
|
||||||
if (!m_udev) {
|
if (!m_udev) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
#if defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_FREEBSD)
|
||||||
std::vector<UdevDevice::Ptr> r;
|
std::vector<std::unique_ptr<UdevDevice>> r;
|
||||||
r.push_back(deviceFromSyspath("/dev/dri/card0"));
|
r.push_back(deviceFromSyspath("/dev/dri/card0"));
|
||||||
return r;
|
return r;
|
||||||
#else
|
#else
|
||||||
|
@ -125,7 +125,7 @@ std::vector<UdevDevice::Ptr> Udev::listGPUs()
|
||||||
enumerate.addMatch(UdevEnumerate::Match::SysName, "card[0-9]");
|
enumerate.addMatch(UdevEnumerate::Match::SysName, "card[0-9]");
|
||||||
enumerate.scan();
|
enumerate.scan();
|
||||||
auto vect = enumerate.find();
|
auto vect = enumerate.find();
|
||||||
std::sort(vect.begin(), vect.end(), [](const UdevDevice::Ptr &device1, const UdevDevice::Ptr &device2) {
|
std::sort(vect.begin(), vect.end(), [](const auto &device1, const auto &device2) {
|
||||||
// prevent usb devices from becoming the primaryGpu
|
// prevent usb devices from becoming the primaryGpu
|
||||||
if (device1->isHotpluggable()) {
|
if (device1->isHotpluggable()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -149,7 +149,7 @@ std::vector<UdevDevice::Ptr> Udev::listGPUs()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
UdevDevice::Ptr Udev::deviceFromSyspath(const char *syspath)
|
std::unique_ptr<UdevDevice> Udev::deviceFromSyspath(const char *syspath)
|
||||||
{
|
{
|
||||||
auto dev = udev_device_new_from_syspath(m_udev, syspath);
|
auto dev = udev_device_new_from_syspath(m_udev, syspath);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
|
@ -282,10 +282,10 @@ void UdevMonitor::enable()
|
||||||
udev_monitor_enable_receiving(m_monitor);
|
udev_monitor_enable_receiving(m_monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
UdevDevice::Ptr UdevMonitor::getDevice()
|
std::unique_ptr<UdevDevice> UdevMonitor::getDevice()
|
||||||
{
|
{
|
||||||
if (!m_monitor) {
|
if (!m_monitor) {
|
||||||
return UdevDevice::Ptr();
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto dev = udev_monitor_receive_device(m_monitor);
|
auto dev = udev_monitor_receive_device(m_monitor);
|
||||||
return dev ? std::make_unique<UdevDevice>(dev) : nullptr;
|
return dev ? std::make_unique<UdevDevice>(dev) : nullptr;
|
||||||
|
|
|
@ -48,7 +48,6 @@ public:
|
||||||
{
|
{
|
||||||
return m_device;
|
return m_device;
|
||||||
}
|
}
|
||||||
typedef std::unique_ptr<UdevDevice> Ptr;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
udev_device *const m_device;
|
udev_device *const m_device;
|
||||||
|
@ -67,7 +66,7 @@ public:
|
||||||
}
|
}
|
||||||
void filterSubsystemDevType(const char *subSystem, const char *devType = nullptr);
|
void filterSubsystemDevType(const char *subSystem, const char *devType = nullptr);
|
||||||
void enable();
|
void enable();
|
||||||
UdevDevice::Ptr getDevice();
|
std::unique_ptr<UdevDevice> getDevice();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
udev_monitor *m_monitor;
|
udev_monitor *m_monitor;
|
||||||
|
@ -83,8 +82,8 @@ public:
|
||||||
{
|
{
|
||||||
return m_udev != nullptr;
|
return m_udev != nullptr;
|
||||||
}
|
}
|
||||||
std::vector<UdevDevice::Ptr> listGPUs();
|
std::vector<std::unique_ptr<UdevDevice>> listGPUs();
|
||||||
UdevDevice::Ptr deviceFromSyspath(const char *syspath);
|
std::unique_ptr<UdevDevice> deviceFromSyspath(const char *syspath);
|
||||||
std::unique_ptr<UdevMonitor> monitor();
|
std::unique_ptr<UdevMonitor> monitor();
|
||||||
operator udev *() const
|
operator udev *() const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue