Simon Glass | b67c18d | 2019-02-16 20:24:55 -0700 | [diff] [blame] | 1 | /* 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 | |
| 13 | struct 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 | */ |
| 21 | struct 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 |
| 30 | * @return 0 if OK -ETIMEDOUT if codec did not respond in time |
| 31 | */ |
| 32 | int 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 |
| 38 | * @return 0 if OK -ETIMEDOUT if codec did not respond in time |
| 39 | */ |
| 40 | int hda_wait_for_valid(struct hda_regs *regs); |
| 41 | |
| 42 | /** |
| 43 | * hda_codec_detect() - Detect which codecs are present |
| 44 | * |
| 45 | * @regs: HDA registers |
| 46 | * @return bit mask of active codecs (0 if none) |
| 47 | * @return 0 if OK, -ve on error |
| 48 | */ |
| 49 | int 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) |
| 57 | * @return 0 if OK, -ve on error |
| 58 | */ |
| 59 | int 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 |
| 69 | * @return if OK, -ve on error |
| 70 | */ |
| 71 | int 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 |
| 79 | * @return if OK, -ve on error |
| 80 | */ |
| 81 | int 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 |
| 89 | * @return 0 if OK, -ve on error |
| 90 | */ |
| 91 | int 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 |
| 99 | * @return 0 if OK, -ve on error |
| 100 | */ |
| 101 | int hda_codec_finish_init(struct udevice *dev); |
| 102 | |
| 103 | #endif /* __HDA_CODEC_H_ */ |