1/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 *
5 * Private declarations for vboot_audio.c. Defined here for easier testing.
6 */
7
8#ifndef VBOOT_REFERENCE_VBOOT_AUDIO_PRIVATE_H_
9#define VBOOT_REFERENCE_VBOOT_AUDIO_PRIVATE_H_
10
11#include "vboot_api.h"
12#include "vboot_audio.h"
13
14typedef struct VbDevMusicNote {
15	uint16_t msec;
16	uint16_t frequency;
17} __attribute__((packed)) VbDevMusicNote;
18
19typedef struct VbDevMusic {
20	uint8_t sig[4];			/* "$SND" */
21	uint32_t checksum;              /* crc32 over count & all notes */
22	uint32_t count;                 /* number of notes */
23	VbDevMusicNote notes[1];        /* gcc allows [0], MSVC doesn't */
24	/* more VbDevMusicNotes follow immediately */
25} __attribute__((packed)) VbDevMusic;
26
27struct VbAudioContext {
28	/* note tracking */
29	VbDevMusicNote *music_notes;
30	uint32_t note_count;
31	uint32_t next_note;
32
33	/* implementation flags */
34	int background_beep;
35	int free_notes_when_done;
36
37	/* sound tracking */
38	uint16_t current_frequency;
39	uint64_t play_until;
40	uint64_t last_time;
41};
42
43#ifdef FOR_TEST
44#define CUSTOM_MUSIC
45#endif
46
47#ifdef CUSTOM_MUSIC
48void *VbExGetMusicPtr(void);
49uint32_t VbExMaxMusicSize(void);
50#define CUSTOM_MUSIC_NOTES VbExGetMusicPtr()
51#define CUSTOM_MUSIC_MAXSIZE VbExMaxMusicSize()
52#else
53#define CUSTOM_MUSIC_NOTES 0
54#define CUSTOM_MUSIC_MAXSIZE 0
55#endif
56
57#endif /* VBOOT_REFERENCE_VBOOT_AUDIO_PRIVATE_H_ */
58