xref: /OK3568_Linux_fs/u-boot/include/sound.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (C) 2012 Samsung Electronics
3  * R. Chandrasekar < rcsekar@samsung.com>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #ifndef __SOUND_H__
9 #define __SOUND_H__
10 
11 /* sound codec enum */
12 enum en_sound_codec {
13 	CODEC_WM_8994,
14 	CODEC_WM_8995,
15 	CODEC_MAX_98095,
16 	CODEC_MAX
17 };
18 
19 /* sound codec enum */
20 enum sound_compat {
21 	AUDIO_COMPAT_SPI,
22 	AUDIO_COMPAT_I2C,
23 };
24 
25 /* Codec information structure to store the info from device tree */
26 struct sound_codec_info {
27 	int i2c_bus;
28 	int i2c_dev_addr;
29 	enum en_sound_codec codec_type;
30 };
31 
32 /*
33  * Generates square wave sound data for 1 second
34  *
35  * @param data          data buffer pointer
36  * @param size          size of the buffer
37  * @param freq          frequency of the wave
38  */
39 void sound_create_square_wave(unsigned short *data, int size, uint32_t freq);
40 
41 /*
42  * Initialises audio sub system
43  * @param blob	Pointer of device tree node or NULL if none.
44  * @return	int value 0 for success, -1 for error
45  */
46 int sound_init(const void *blob);
47 
48 /*
49  * plays the pcm data buffer in pcm_data.h through i2s1 to make the
50  * sine wave sound
51  *
52  * @return	int 0 for success, -1 for error
53  */
54 int sound_play(uint32_t msec, uint32_t frequency);
55 
56 struct snd_soc_dai_ops {
57 	int (*hw_params)(struct udevice *dev, unsigned int samplerate,
58 			 unsigned int fmt, unsigned int channels);
59 	int (*startup)(struct udevice *dev);
60 	int (*shutdown)(struct udevice *dev);
61 	int (*transfer)(struct udevice *dev, unsigned int *data,
62 			unsigned long data_size);
63 	int (*set_sysclk)(struct udevice *dev, unsigned int freq);
64 };
65 
66 #endif  /* __SOUND__H__ */
67