coreboot/src/device
Nicholas Sudsgaard 31fc5b06a6 device: Introduce reworked azalia verb table
The current implementation of the HDA verb table has been shown to have
some problems. The primary issue is that it requires the programmer to
keep track of the amount of verbs that are going to be loaded. While
this may sound simple, in practice there have been numerous cases where
this "count field" has been forgotten to be updated or miscounted. In
the case where the "count field" is incorrect, coreboot will start
looking for codecs in some random memory location, essentially making
loading further codecs impossible.

Another issue is the "count field" treats 4 32-bit values as a single
group, therefore the amount of verbs in the table must be a multiple
of 4. This makes intuitive sense when only using the AZALIA_PIN_CFG() or
AZALIA_SUBVENDOR() macros. However, once the verb table requires
"controls" that use < 4 verbs (e.g. "Coefficient Index"), we need to add
padding values to ensure the alignment is correct. This adds unnecessary
verbs to the table which can further lead to unnecessary processing.

Therefore, in this change we proprose a solution by separating the codec
entries in the verb table into structures, which allows us to separate
the verbs into an array and automatically calculate the "count field"
using the ARRAY_SIZE() macro. It also makes iteration and access to
member fields easier. We also now count the verbs and not 4 32-bit
groups, eliminating the aforementioned alignment issue.

Additionally, this change also changes the way coreboot searches for
entries in the verb table. Before, we searched the table for only a
matching vendor ID, but now we search for a matching vendor ID and
codec address pair. This allows a mainboard to be able to correctly load
multiple audio codecs that use the same chips.

To make reviewing this large rework easier, we temporarily keep both
implementations (legacy and reworked) and allow boards to choose which
implementation to use by selecting a Kconfig. Newer boards are
discouraged from using the legacy implementation, as it is not selected
by default. This allows us to slowly change the codebase instead of
changing everything at once.

TEST=
  1. Timeless build with AZALIA_USE_LEGACY_VERB_TABLE=y produces
     identical binaries (with INCLUDE_CONFIG_FILE=n)
  2. HP ProBook 450 G3 using reworked verb table was able to load all
     verbs successfully.

Change-Id: Ib16237de89956405afa3be5b4e3f64a4d62e6a48
Signed-off-by: Nicholas Sudsgaard <devel+coreboot@nsudsgaard.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88656
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-09-28 18:18:14 +00:00
..
dram device/dram: Rename 'USE_DDRx' config options 2025-07-25 17:03:02 +00:00
oprom arch/x86: Unify GDT entries 2025-05-08 12:29:24 +00:00
azalia_device.c device: Introduce reworked azalia verb table 2025-09-28 18:18:14 +00:00
cardbus_device.c device/device.h: Rename busses for clarity 2024-01-31 10:36:39 +00:00
cpu_device.c cpu/x86/topology: Add code to fill in topology on struct path 2023-04-06 15:27:23 +00:00
device.c device/device.h: Fix spelling mistake 2024-01-31 10:36:49 +00:00
device_const.c arch/x86: Enable support for IOAPIC devices 2024-12-06 20:57:44 +00:00
device_util.c device/device_util: Fix format specifier for DEVICE_PATH_GICC_V3 2025-08-15 19:00:14 +00:00
gpio.c src/device: Clean up includes 2022-10-26 16:38:11 +00:00
i2c.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
i2c_bus.c device/device.h: Rename busses for clarity 2024-01-31 10:36:39 +00:00
Kconfig device: Add Kconfig to prepare for reworked verb table implementation 2025-09-28 18:18:03 +00:00
Makefile.mk device, security: Rename Makefiles from .inc to .mk 2024-01-24 10:13:21 +00:00
mdio.c device/device.h: Rename busses for clarity 2024-01-31 10:36:39 +00:00
mmio.c tree: Remove blank lines before '}' and after '{' 2024-04-11 19:19:08 +00:00
pci_class.c arch to drivers/intel: Fix misspellings & capitalization issues 2023-09-08 00:53:57 +00:00
pci_device.c device/pci_device: Fix typo in comments 2025-09-26 19:04:54 +00:00
pci_early.c treewide: Remove duplicated include <device/pci.h> 2023-02-01 03:03:34 +00:00
pci_ops.c treewide: Remove duplicated include <device/pci.h> 2023-02-01 03:03:34 +00:00
pci_rom.c device/pci_device: Move PCI Option ROM code into pci_rom.c 2025-03-10 11:35:57 +00:00
pciexp_device.c pci: Add support for assigning resources to SR-IOV VF BARs 2025-05-27 15:10:48 +00:00
pcix_device.c device/device.h: Rename busses for clarity 2024-01-31 10:36:39 +00:00
pnp_device.c device/pnp_device: fix log levels for unassigned resource messages 2024-02-29 21:40:49 +00:00
resource_allocator_common.c src/device: Clean up includes 2022-10-26 16:38:11 +00:00
resource_allocator_v4.c tree: Remove blank lines before '}' and after '{' 2024-04-11 19:19:08 +00:00
root_device.c device/device.h: Rename busses for clarity 2024-01-31 10:36:39 +00:00
smbus_ops.c console: Add format-checking __printf() to die() 2023-05-17 11:23:59 +00:00
software_i2c.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
xhci.c device/xhci: Add functions to work with resource pointers 2023-03-05 15:32:34 +00:00
xhci_resource.c device/xhci: Add functions to work with resource pointers 2023-03-05 15:32:34 +00:00