summaryrefslogtreecommitdiff
path: root/util/autoport/azalia.go
blob: c98b03cdea6ecddbcc178e8c98e85a68f6ddc699 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main

import (
	"fmt"
	"sort"
)

type azalia struct {
}

func (i azalia) Scan(ctx Context, addr PCIDevData) {
	az := Create(ctx, "hda_verb.c")
	defer az.Close()

	Add_gpl(az)
	az.WriteString(
		`#include <device/azalia_device.h>

const u32 cim_verb_data[] = {
`)

	for _, codec := range ctx.InfoSource.GetAzaliaCodecs() {
		fmt.Fprintf(az, "\t0x%08x,\t/* Codec Vendor / Device ID: %s */\n",
			codec.VendorID, codec.Name)
		fmt.Fprintf(az, "\t0x%08x,\t/* Subsystem ID */\n",
			codec.SubsystemID)
		fmt.Fprintf(az, "\t%d,\t\t/* Number of 4 dword sets */\n",
			len(codec.PinConfig)+1)
		fmt.Fprintf(az, "\tAZALIA_SUBVENDOR(%d, 0x%08x),\n",
			codec.CodecNo, codec.SubsystemID)

		keys := []int{}
		for nid, _ := range codec.PinConfig {
			keys = append(keys, nid)
		}

		sort.Ints(keys)

		for _, nid := range keys {
			fmt.Fprintf(az, "\tAZALIA_PIN_CFG(%d, 0x%02x, 0x%08x),\n",
				codec.CodecNo, nid, codec.PinConfig[nid])
		}
		az.WriteString("\n");
	}

	az.WriteString(
		`};

const u32 pc_beep_verbs[0] = {};

AZALIA_ARRAY_SIZES;
`)

	PutPCIDev(addr, "")
}

func init() {
	/* I82801GX/I945 */
	RegisterPCI(0x8086, 0x27d8, azalia{})
	/* BD82X6X/sandybridge */
	RegisterPCI(0x8086, 0x1c20, azalia{})
	/* C216/ivybridge */
	RegisterPCI(0x8086, 0x1e20, azalia{})
}