Felix Held submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved
autoport: search for the HDA device on PCH

Haswell has its Mini-HD device and is at card0, so we need to search
for the PCH HD Audio device instead of using card0.

Change-Id: I2bc420fdbe9731ae835f63add85db79f04201da4
Signed-off-by: Iru Cai <mytbk920423@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34357
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M util/autoport/log_maker.go
M util/autoport/log_reader.go
2 files changed, 67 insertions(+), 32 deletions(-)

diff --git a/util/autoport/log_maker.go b/util/autoport/log_maker.go
index 08b35d2..2a524d3 100644
--- a/util/autoport/log_maker.go
+++ b/util/autoport/log_maker.go
@@ -9,6 +9,7 @@
"os"
"os/exec"
"strings"
+ "bytes"
)

func TryRunAndSave(output string, name string, arg []string) error {
@@ -74,6 +75,44 @@
return
}

+func MakeHDALogs(outDir string, cardName string) {
+ SysDir := "/sys/class/sound/" + cardName + "/"
+ files, _ := ioutil.ReadDir(SysDir)
+ for _, f := range files {
+ if (strings.HasPrefix(f.Name(), "hw") || strings.HasPrefix(f.Name(), "hdaudio")) && f.IsDir() {
+ in, err := os.Open(SysDir + f.Name() + "/init_pin_configs")
+ defer in.Close()
+ if err != nil {
+ log.Fatal(err)
+ }
+ out, err := os.Create(outDir + "/pin_" + strings.Replace(f.Name(), "hdaudio", "hw", -1))
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer out.Close()
+ io.Copy(out, in)
+ }
+ }
+
+ ProcDir := "/proc/asound/" + cardName + "/"
+ files, _ = ioutil.ReadDir(ProcDir)
+ for _, f := range files {
+ if strings.HasPrefix(f.Name(), "codec#") && !f.IsDir() {
+ in, err := os.Open(ProcDir + f.Name())
+ defer in.Close()
+ if err != nil {
+ log.Fatal(err)
+ }
+ out, err := os.Create(outDir + "/" + f.Name())
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer out.Close()
+ io.Copy(out, in)
+ }
+ }
+}
+
func MakeLogs(outDir string) {
os.MkdirAll(outDir, 0700)
RunAndSave(outDir+"/lspci.log", "lspci", "-nnvvvxxxx")
@@ -97,40 +136,23 @@
RunAndSave(outDir+"/ectool.log", "../ectool/ectool", "-pd")
RunAndSave(outDir+"/superiotool.log", "../superiotool/superiotool", "-ade")

- SysDir := "/sys/class/sound/card0/"
- files, _ := ioutil.ReadDir(SysDir)
- for _, f := range files {
- if (strings.HasPrefix(f.Name(), "hw") || strings.HasPrefix(f.Name(), "hdaudio")) && f.IsDir() {
- in, err := os.Open(SysDir + f.Name() + "/init_pin_configs")
- defer in.Close()
- if err != nil {
- log.Fatal(err)
+ SysSound := "/sys/class/sound/"
+ card := ""
+ cards, _ := ioutil.ReadDir(SysSound)
+ for _, f := range cards {
+ if strings.HasPrefix(f.Name(), "card") {
+ cid, err := ioutil.ReadFile(SysSound + f.Name() + "/id")
+ if err == nil && bytes.Equal(cid, []byte("PCH\n")) {
+ fmt.Fprintln(os.Stderr, "PCH sound card is", f.Name())
+ card = f.Name()
}
- out, err := os.Create(outDir + "/pin_" + strings.Replace(f.Name(), "hdaudio", "hw", -1))
- if err != nil {
- log.Fatal(err)
- }
- defer out.Close()
- io.Copy(out, in)
}
}

- ProcDir := "/proc/asound/card0/"
- files, _ = ioutil.ReadDir(ProcDir)
- for _, f := range files {
- if strings.HasPrefix(f.Name(), "codec#") && !f.IsDir() {
- in, err := os.Open(ProcDir + f.Name())
- defer in.Close()
- if err != nil {
- log.Fatal(err)
- }
- out, err := os.Create(outDir + "/" + f.Name())
- if err != nil {
- log.Fatal(err)
- }
- defer out.Close()
- io.Copy(out, in)
- }
+ if card != "" {
+ MakeHDALogs(outDir, card)
+ } else {
+ fmt.Fprintln(os.Stderr, "HDAudio not found on PCH.")
}

for _, fname := range []string{"cpuinfo", "ioports"} {
@@ -154,7 +176,7 @@
defer out.Close()

ClassInputDir := "/sys/class/input/"
- files, _ = ioutil.ReadDir(ClassInputDir)
+ files, _ := ioutil.ReadDir(ClassInputDir)
for _, f := range files {
if strings.HasPrefix(f.Name(), "input") && !f.Mode().IsRegular() { /* Allow both dirs and symlinks. */
in, err := os.Open(ClassInputDir + f.Name() + "/id/bustype")
diff --git a/util/autoport/log_reader.go b/util/autoport/log_reader.go
index 0aaf6a9..b144804 100644
--- a/util/autoport/log_reader.go
+++ b/util/autoport/log_reader.go
@@ -251,6 +251,18 @@
}

func (l *LogDevReader) GetAzaliaCodecs() (ret []AzaliaCodec) {
+ cardno := -1
+ for i := 0; i < 10; i++ {
+ pin, err := os.Open(l.InputDirectory + "/pin_hwC" + strconv.Itoa(i) + "D0")
+ if err == nil {
+ pin.Close()
+ cardno = i
+ break
+ }
+ }
+ if cardno == -1 {
+ return
+ }
for codecno := 0; codecno < 10; codecno++ {
cur := AzaliaCodec{CodecNo: codecno, PinConfig: map[int]uint32{}}
codec, err := os.Open(l.InputDirectory + "/codec#" + strconv.Itoa(codecno))
@@ -258,7 +270,8 @@
continue
}
defer codec.Close()
- pin, err := os.Open(l.InputDirectory + "/pin_hwC0D" + strconv.Itoa(codecno))
+ pin, err := os.Open(l.InputDirectory + "/pin_hwC" + strconv.Itoa(cardno) +
+ "D" + strconv.Itoa(codecno))
if err != nil {
continue
}

To view, visit change 34357. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I2bc420fdbe9731ae835f63add85db79f04201da4
Gerrit-Change-Number: 34357
Gerrit-PatchSet: 25
Gerrit-Owner: Iru Cai <mytbk920423@gmail.com>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Felix Held <felix-coreboot@felixheld.de>
Gerrit-Reviewer: Iru Cai <mytbk920423@gmail.com>
Gerrit-Reviewer: Pablo Stebler <pablo@stebler.xyz>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@mailbox.org>
Gerrit-MessageType: merged