blob: 247eafe66e20524eb80830860ba369cd82c91293 [file] [log] [blame]
Simon Glass2ca47132019-02-16 20:24:55 -07001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Support for Intel High-Definition Audio codec
4 *
5 * Copyright 2018 Google LLC
6 *
7 * Taken from coreboot file of the same name
8 */
9
10#ifndef __HDA_CODEC_H_
11#define __HDA_CODEC_H_
12
13struct hda_regs;
14
15/**
16 * struct hda_codec_priv - Private data required by the HDA codec
17 *
18 * @regs: HDA registers
19 * @beep_nid: Node ID of beep node (>0)
20 */
21struct hda_codec_priv {
22 struct hda_regs *regs;
23 uint beep_nid;
24};
25
26/**
27 * hda_wait_for_ready() - Wait for the codec to indicate it is ready
28 *
29 * @regs: HDA registers
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010030 * Return: 0 if OK -ETIMEDOUT if codec did not respond in time
Simon Glass2ca47132019-02-16 20:24:55 -070031 */
32int hda_wait_for_ready(struct hda_regs *regs);
33
34/**
35 * hda_wait_for_valid() - Wait for the codec to accept the last command
36 *
37 * @regs: HDA registers
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010038 * Return: 0 if OK -ETIMEDOUT if codec did not respond in time
Simon Glass2ca47132019-02-16 20:24:55 -070039 */
40int hda_wait_for_valid(struct hda_regs *regs);
41
42/**
43 * hda_codec_detect() - Detect which codecs are present
44 *
45 * @regs: HDA registers
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010046 * Return: bit mask of active codecs (0 if none)
47 * Return: 0 if OK, -ve on error
Simon Glass2ca47132019-02-16 20:24:55 -070048 */
49int hda_codec_detect(struct hda_regs *regs);
50
51/**
52 * hda_codecs_init() - Init all codecs
53 *
54 * @dev: Sound device
55 * @regs: HDA registers
56 * @codec_mask: Mask of codecs to init (bits 3:0)
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010057 * Return: 0 if OK, -ve on error
Simon Glass2ca47132019-02-16 20:24:55 -070058 */
59int hda_codecs_init(struct udevice *dev, struct hda_regs *regs, u32 codec_mask);
60
61/**
62 * hda_codec_start_beep() - Start beeping
63 *
64 * This tells the sound hardware to start a beep. It will continue until stopped
65 * by sound_stop_beep().
66 *
67 * @dev: Sound device
68 * @frequency_hz: Beep frequency in hertz
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010069 * Return: if OK, -ve on error
Simon Glass2ca47132019-02-16 20:24:55 -070070 */
71int hda_codec_start_beep(struct udevice *dev, int frequency_hz);
72
73/**
74 * hda_codec_stop_beep() - Stop beeping
75 *
76 * This tells the sound hardware to stop a previously started beep.
77 *
78 * @dev: Sound device
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010079 * Return: if OK, -ve on error
Simon Glass2ca47132019-02-16 20:24:55 -070080 */
81int hda_codec_stop_beep(struct udevice *dev);
82
83/**
84 * hda_codec_init() - Set up the HDA codec base address
85 *
86 * This should be called at the start of the probe() method.
87 *
88 * @dev: Sound device
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010089 * Return: 0 if OK, -ve on error
Simon Glass2ca47132019-02-16 20:24:55 -070090 */
91int hda_codec_init(struct udevice *dev);
92
93/**
94 * hda_codec_finish_init() - Finish setting up the HDA codec base address
95 *
96 * This should be called at the end of the probe() method.
97 *
98 * @dev: Sound device
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010099 * Return: 0 if OK, -ve on error
Simon Glass2ca47132019-02-16 20:24:55 -0700100 */
101int hda_codec_finish_init(struct udevice *dev);
102
103#endif /* __HDA_CODEC_H_ */