Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Rajeshwari Shinde | 836a66c | 2012-10-25 19:49:22 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2012 Samsung Electronics |
| 4 | * R. Chandrasekar < rcsekar@samsung.com> |
Rajeshwari Shinde | 836a66c | 2012-10-25 19:49:22 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __SOUND_H__ |
| 8 | #define __SOUND_H__ |
| 9 | |
| 10 | /* sound codec enum */ |
| 11 | enum en_sound_codec { |
| 12 | CODEC_WM_8994, |
| 13 | CODEC_WM_8995, |
Rajeshwari Shinde | 1bf5825 | 2013-02-14 19:46:13 +0000 | [diff] [blame] | 14 | CODEC_MAX_98095, |
Rajeshwari Shinde | 836a66c | 2012-10-25 19:49:22 +0000 | [diff] [blame] | 15 | CODEC_MAX |
| 16 | }; |
| 17 | |
| 18 | /* sound codec enum */ |
| 19 | enum sound_compat { |
| 20 | AUDIO_COMPAT_SPI, |
| 21 | AUDIO_COMPAT_I2C, |
| 22 | }; |
| 23 | |
| 24 | /* Codec information structure to store the info from device tree */ |
| 25 | struct sound_codec_info { |
| 26 | int i2c_bus; |
| 27 | int i2c_dev_addr; |
| 28 | enum en_sound_codec codec_type; |
| 29 | }; |
| 30 | |
| 31 | /* |
Simon Glass | 59c021e | 2014-02-27 13:26:20 -0700 | [diff] [blame] | 32 | * Generates square wave sound data for 1 second |
| 33 | * |
Simon Glass | ddad032 | 2018-11-15 19:56:13 -0700 | [diff] [blame] | 34 | * @param sample_rate Sample rate in Hz |
Simon Glass | 59c021e | 2014-02-27 13:26:20 -0700 | [diff] [blame] | 35 | * @param data data buffer pointer |
| 36 | * @param size size of the buffer |
| 37 | * @param freq frequency of the wave |
| 38 | */ |
Simon Glass | ddad032 | 2018-11-15 19:56:13 -0700 | [diff] [blame] | 39 | void sound_create_square_wave(uint sample_rate, unsigned short *data, int size, |
| 40 | uint freq); |
Simon Glass | 59c021e | 2014-02-27 13:26:20 -0700 | [diff] [blame] | 41 | |
| 42 | /* |
Rajeshwari Shinde | 836a66c | 2012-10-25 19:49:22 +0000 | [diff] [blame] | 43 | * Initialises audio sub system |
Rajeshwari Shinde | 7376621 | 2012-12-26 20:03:17 +0000 | [diff] [blame] | 44 | * @param blob Pointer of device tree node or NULL if none. |
Rajeshwari Shinde | 836a66c | 2012-10-25 19:49:22 +0000 | [diff] [blame] | 45 | * @return int value 0 for success, -1 for error |
| 46 | */ |
Rajeshwari Shinde | 7376621 | 2012-12-26 20:03:17 +0000 | [diff] [blame] | 47 | int sound_init(const void *blob); |
Rajeshwari Shinde | 836a66c | 2012-10-25 19:49:22 +0000 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * plays the pcm data buffer in pcm_data.h through i2s1 to make the |
| 51 | * sine wave sound |
| 52 | * |
| 53 | * @return int 0 for success, -1 for error |
| 54 | */ |
| 55 | int sound_play(uint32_t msec, uint32_t frequency); |
| 56 | |
| 57 | #endif /* __SOUND__H__ */ |