coreboot/util/autoport/azalia.go
Nicholas Chin 2a2c78aeea util/autoport: Make printing of SPDX headers generic
Previously, Add_gpl() was only used with C and ASL source code files,
and was hard coded to use the C /* */ style comment, preventing it from
being used with files with other comment styles. Convert this into a
generic function for adding arbitrary SPDX license identifiers for
arbitrary filetypes. This replaces the hard coded GPL-2.0-or-later
string used in gma-mainboard.ads with a call to the new function.

This is also used to add SPDX headers to Kconfig and Makefile sources;
as previous commits added them to all such files in the tree.

Tested against logs from a Latitude E6430 (Ivy Bridge) and Precision
M6800 (Haswell) to check that license headers that were already being
generated did not change.

Change-Id: I24a1ccd0afb7045e878bf6eaae7a23f828a9240d
Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/83184
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2024-09-13 14:18:48 +00:00

67 lines
1.4 KiB
Go

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_SPDX(az, C, GPL2_only)
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{})
/* Lynx Point */
RegisterPCI(0x8086, 0x8c20, azalia{})
RegisterPCI(0x8086, 0x9c20, azalia{})
}