1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2012 Samsung Electronics
4 * R. Chandrasekar < rcsekar@samsung.com>
10 /* sound codec enum */
16 /* Codec information structure to store the info from device tree */
17 struct sound_codec_info {
23 * struct sound_uc_priv - private uclass information about each sound device
25 * This is used to line the codec and i2s together
27 * @codec: Codec that is used for this sound device
28 * @i2s: I2S bus that is used for this sound device
29 * @setup_done: true if setup() has been called
31 struct sound_uc_priv {
32 struct udevice *codec;
38 * Generates square wave sound data for 1 second
40 * @param sample_rate Sample rate in Hz
41 * @param data data buffer pointer
42 * @param size size of the buffer in bytes
43 * @param freq frequency of the wave
45 void sound_create_square_wave(uint sample_rate, unsigned short *data, int size,
49 * The sound uclass brings together a data transport (currently only I2C) and a
50 * codec (currently connected over I2C).
53 /* Operations for sound */
56 * setup() - Set up to play a sound
58 int (*setup)(struct udevice *dev);
61 * play() - Play a beep
64 * @data: Data buffer to play
65 * @data_size: Size of data buffer in bytes
66 * @return 0 if OK, -ve on error
68 int (*play)(struct udevice *dev, void *data, uint data_size);
71 #define sound_get_ops(dev) ((struct sound_ops *)(dev)->driver->ops)
74 * setup() - Set up to play a sound
76 int sound_setup(struct udevice *dev);
79 * play() - Play a beep
82 * @msecs: Duration of beep in milliseconds
83 * @frequency_hz: Frequency of the beep in Hertz
84 * @return 0 if OK, -ve on error
86 int sound_beep(struct udevice *dev, int msecs, int frequency_hz);
89 * sound_find_codec_i2s() - Called by sound drivers to locate codec and i2s
91 * This finds the audio codec and i2s devices and puts them in the uclass's
92 * private data for this device.
94 int sound_find_codec_i2s(struct udevice *dev);
96 #endif /* __SOUND__H__ */