|
|
121cca |
From 1cc52cac74ea735faae92dc963d10292608d7a4d Mon Sep 17 00:00:00 2001
|
|
|
121cca |
From: Lyonel Vincent <lyonel@ezix.org>
|
|
|
121cca |
Date: Thu, 2 Apr 2020 13:39:42 +0200
|
|
|
121cca |
Subject: [PATCH 09/65] detect sound devices
|
|
|
121cca |
|
|
|
121cca |
---
|
|
|
121cca |
src/core/main.cc | 4 ++++
|
|
|
121cca |
src/core/sound.cc | 53 +++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
121cca |
src/core/sound.h | 8 +++++++
|
|
|
121cca |
src/core/sysfs.cc | 5 +++++
|
|
|
121cca |
src/core/sysfs.h | 1 +
|
|
|
121cca |
6 files changed, 72 insertions(+), 1 deletion(-)
|
|
|
121cca |
create mode 100644 src/core/sound.cc
|
|
|
121cca |
create mode 100644 src/core/sound.h
|
|
|
121cca |
|
|
|
121cca |
diff --git a/src/core/main.cc b/src/core/main.cc
|
|
|
121cca |
index ad0e586..e35258c 100644
|
|
|
121cca |
--- a/src/core/main.cc
|
|
|
121cca |
+++ b/src/core/main.cc
|
|
|
121cca |
@@ -46,6 +46,7 @@
|
|
|
121cca |
#include "nvme.h"
|
|
|
121cca |
#include "mmc.h"
|
|
|
121cca |
#include "input.h"
|
|
|
121cca |
+#include "sound.h"
|
|
|
121cca |
#include "smp.h"
|
|
|
121cca |
#include "abi.h"
|
|
|
121cca |
#include "s390.h"
|
|
|
121cca |
@@ -141,6 +142,9 @@ bool scan_system(hwNode & system)
|
|
|
121cca |
status("MMC");
|
|
|
121cca |
if (enabled("mmc"))
|
|
|
121cca |
scan_mmc(computer);
|
|
|
121cca |
+ status("sound");
|
|
|
121cca |
+ if (enabled("sound"))
|
|
|
121cca |
+ scan_sound(computer);
|
|
|
121cca |
status("input");
|
|
|
121cca |
if (enabled("input"))
|
|
|
121cca |
scan_input(computer);
|
|
|
121cca |
diff --git a/src/core/sound.cc b/src/core/sound.cc
|
|
|
121cca |
new file mode 100644
|
|
|
121cca |
index 0000000..05edf23
|
|
|
121cca |
--- /dev/null
|
|
|
121cca |
+++ b/src/core/sound.cc
|
|
|
121cca |
@@ -0,0 +1,53 @@
|
|
|
121cca |
+#include "version.h"
|
|
|
121cca |
+#include "hw.h"
|
|
|
121cca |
+#include "sysfs.h"
|
|
|
121cca |
+#include "osutils.h"
|
|
|
121cca |
+#include "sound.h"
|
|
|
121cca |
+#include "heuristics.h"
|
|
|
121cca |
+
|
|
|
121cca |
+#include <vector>
|
|
|
121cca |
+#include <iostream>
|
|
|
121cca |
+
|
|
|
121cca |
+__ID("@(#) $Id$");
|
|
|
121cca |
+
|
|
|
121cca |
+using namespace std;
|
|
|
121cca |
+
|
|
|
121cca |
+bool scan_sound(hwNode & n)
|
|
|
121cca |
+{
|
|
|
121cca |
+ vector < sysfs::entry > entries = sysfs::entries_by_class("sound");
|
|
|
121cca |
+
|
|
|
121cca |
+ if (entries.empty())
|
|
|
121cca |
+ return false;
|
|
|
121cca |
+
|
|
|
121cca |
+ for (vector < sysfs::entry >::iterator it = entries.begin();
|
|
|
121cca |
+ it != entries.end(); ++it)
|
|
|
121cca |
+ {
|
|
|
121cca |
+ const sysfs::entry & e = *it;
|
|
|
121cca |
+ string id = e.string_attr("id");
|
|
|
121cca |
+ if(id!="")
|
|
|
121cca |
+ {
|
|
|
121cca |
+ hwNode *device = n.findChildByBusInfo(e.leaf().businfo());
|
|
|
121cca |
+ if(!device)
|
|
|
121cca |
+ device = n.addChild(hwNode("sound", hw::multimedia));
|
|
|
121cca |
+ device->claim();
|
|
|
121cca |
+ if(device->getDescription() == "") device->setDescription(id);
|
|
|
121cca |
+ //device->setPhysId(e.hex_attr("number"));
|
|
|
121cca |
+ //device->setBusInfo("sound@"+e.string_attr("number"));
|
|
|
121cca |
+ device->setLogicalName("snd/"+e.name());
|
|
|
121cca |
+ if(device->getProduct() == "") device->setProduct(e.string_attr("name"));
|
|
|
121cca |
+ device->setModalias(e.modalias());
|
|
|
121cca |
+
|
|
|
121cca |
+ vector < sysfs::entry > events = e.devices();
|
|
|
121cca |
+ for(vector < sysfs::entry >::iterator i = events.begin(); i != events.end(); ++i)
|
|
|
121cca |
+ {
|
|
|
121cca |
+ const sysfs::entry & d = *i;
|
|
|
121cca |
+ if(d.subsystem() == "sound")
|
|
|
121cca |
+ {
|
|
|
121cca |
+ device->setLogicalName("snd/"+d.name());
|
|
|
121cca |
+ }
|
|
|
121cca |
+ }
|
|
|
121cca |
+ }
|
|
|
121cca |
+ }
|
|
|
121cca |
+
|
|
|
121cca |
+ return true;
|
|
|
121cca |
+}
|
|
|
121cca |
diff --git a/src/core/sound.h b/src/core/sound.h
|
|
|
121cca |
new file mode 100644
|
|
|
121cca |
index 0000000..c2caf04
|
|
|
121cca |
--- /dev/null
|
|
|
121cca |
+++ b/src/core/sound.h
|
|
|
121cca |
@@ -0,0 +1,8 @@
|
|
|
121cca |
+#ifndef _SOUND_H_
|
|
|
121cca |
+#define _SOUND_H_
|
|
|
121cca |
+
|
|
|
121cca |
+#include "hw.h"
|
|
|
121cca |
+
|
|
|
121cca |
+bool scan_sound(hwNode &);
|
|
|
121cca |
+
|
|
|
121cca |
+#endif
|
|
|
121cca |
diff --git a/src/core/sysfs.cc b/src/core/sysfs.cc
|
|
|
121cca |
index 32d6564..ee8b1da 100644
|
|
|
121cca |
--- a/src/core/sysfs.cc
|
|
|
121cca |
+++ b/src/core/sysfs.cc
|
|
|
121cca |
@@ -343,6 +343,11 @@ string entry::classname() const
|
|
|
121cca |
return basename(dirname(This->devpath).c_str());
|
|
|
121cca |
}
|
|
|
121cca |
|
|
|
121cca |
+string entry::subsystem() const
|
|
|
121cca |
+{
|
|
|
121cca |
+ return basename(realpath(This->devpath+"/subsystem").c_str());
|
|
|
121cca |
+}
|
|
|
121cca |
+
|
|
|
121cca |
bool entry::isvirtual() const
|
|
|
121cca |
{
|
|
|
121cca |
return string(basename(dirname(dirname(This->devpath)).c_str())) == "virtual";
|
|
|
121cca |
diff --git a/src/core/sysfs.h b/src/core/sysfs.h
|
|
|
121cca |
index 9cc1b2b..c25430b 100644
|
|
|
121cca |
--- a/src/core/sysfs.h
|
|
|
121cca |
+++ b/src/core/sysfs.h
|
|
|
121cca |
@@ -26,6 +26,7 @@ namespace sysfs
|
|
|
121cca |
bool hassubdir(const string &) const;
|
|
|
121cca |
string name() const;
|
|
|
121cca |
string classname() const;
|
|
|
121cca |
+ string subsystem() const;
|
|
|
121cca |
bool isvirtual() const;
|
|
|
121cca |
string businfo() const;
|
|
|
121cca |
string driver() const;
|
|
|
121cca |
--
|
|
|
121cca |
2.33.1
|
|
|
121cca |
|