summaryrefslogtreecommitdiffstats
path: root/include/hda_codec.h
blob: 56de571f0f71146ca7b29916b143a09d8a435cd1 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Support for Intel High-Definition Audio codec
 *
 * Copyright 2018 Google LLC
 *
 * Taken from coreboot file of the same name
 */

#ifndef __HDA_CODEC_H_
#define __HDA_CODEC_H_

struct hda_regs;

/**
 * struct hda_codec_priv - Private data required by the HDA codec
 *
 * @regs: HDA registers
 * @beep_nid: Node ID of beep node (>0)
 */
struct hda_codec_priv {
	struct hda_regs *regs;
	uint beep_nid;
};

/**
 *  hda_wait_for_ready() - Wait for the codec to indicate it is ready
 *
 * @regs: HDA registers
 * @return 0 if OK -ETIMEDOUT if codec did not respond in time
 */
int hda_wait_for_ready(struct hda_regs *regs);

/**
 *  hda_wait_for_valid() - Wait for the codec to accept the last command
 *
 * @regs: HDA registers
 * @return 0 if OK -ETIMEDOUT if codec did not respond in time
 */
int hda_wait_for_valid(struct hda_regs *regs);

/**
 * hda_codec_detect() - Detect which codecs are present
 *
 * @regs: HDA registers
 * @return bit mask of active codecs (0 if none)
 * @return 0 if OK, -ve on error
 */
int hda_codec_detect(struct hda_regs *regs);

/**
 * hda_codecs_init() - Init all codecs
 *
 * @dev: Sound device
 * @regs: HDA registers
 * @codec_mask: Mask of codecs to init (bits 3:0)
 * @return 0 if OK, -ve on error
 */
int hda_codecs_init(struct udevice *dev, struct hda_regs *regs, u32 codec_mask);

/**
 * hda_codec_start_beep() - Start beeping
 *
 * This tells the sound hardware to start a beep. It will continue until stopped
 * by sound_stop_beep().
 *
 * @dev: Sound device
 * @frequency_hz: Beep frequency in hertz
 * @return if OK, -ve on error
 */
int hda_codec_start_beep(struct udevice *dev, int frequency_hz);

/**
 * hda_codec_stop_beep() - Stop beeping
 *
 * This tells the sound hardware to stop a previously started beep.
 *
 * @dev: Sound device
 * @return if OK, -ve on error
 */
int hda_codec_stop_beep(struct udevice *dev);

/**
 * hda_codec_init() - Set up the HDA codec base address
 *
 * This should be called at the start of the probe() method.
 *
 * @dev: Sound device
 * @return 0 if OK, -ve on error
 */
int hda_codec_init(struct udevice *dev);

/**
 * hda_codec_finish_init() - Finish setting up the HDA codec base address
 *
 * This should be called at the end of the probe() method.
 *
 * @dev: Sound device
 * @return 0 if OK, -ve on error
 */
int hda_codec_finish_init(struct udevice *dev);

#endif /* __HDA_CODEC_H_ */