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 * @sample_rate: Sample rate in Hz
41 * @data: data buffer pointer
42 * @size: size of the buffer in bytes
43 * @freq: frequency of the wave
44 * @channels: Number of channels to use
46 void sound_create_square_wave(uint sample_rate, unsigned short *data, int size,
47 uint freq, uint channels);
50 * The sound uclass brings together a data transport (currently only I2C) and a
51 * codec (currently connected over I2C).
54 /* Operations for sound */
57 * setup() - Set up to play a sound (optional)
59 int (*setup)(struct udevice *dev);
62 * play() - Play a beep
65 * @data: Data buffer to play
66 * @data_size: Size of data buffer in bytes
67 * @return 0 if OK, -ve on error
69 int (*play)(struct udevice *dev, void *data, uint data_size);
72 * start_beep() - Start beeping (optional)
74 * This tells the sound hardware to start a beep. It will continue until
75 * stopped by sound_stop_beep().
78 * @frequency_hz: Beep frequency in hertz
79 * @return if OK, -ENOSYS if not supported, -ve on error
81 int (*start_beep)(struct udevice *dev, int frequency_hz);
84 * stop_beep() - Stop beeping (optional)
86 * This tells the sound hardware to stop a previously started beep.
89 * @return if OK, -ve on error
91 int (*stop_beep)(struct udevice *dev);
94 #define sound_get_ops(dev) ((struct sound_ops *)(dev)->driver->ops)
97 * setup() - Set up to play a sound
99 int sound_setup(struct udevice *dev);
102 * play() - Play a beep
105 * @msecs: Duration of beep in milliseconds
106 * @frequency_hz: Frequency of the beep in Hertz
107 * @return 0 if OK, -ve on error
109 int sound_beep(struct udevice *dev, int msecs, int frequency_hz);
112 * sound_start_beep() - Start beeping
114 * This tells the sound hardware to start a beep. It will continue until stopped
115 * by sound_stop_beep().
118 * @frequency_hz: Beep frequency in hertz
119 * @return if OK, -ve on error
121 int sound_start_beep(struct udevice *dev, int frequency_hz);
124 * sound_stop_beep() - Stop beeping
126 * This tells the sound hardware to stop a previously started beep.
129 * @return if OK, -ve on error
131 int sound_stop_beep(struct udevice *dev);
134 * sound_find_codec_i2s() - Called by sound drivers to locate codec and i2s
136 * This finds the audio codec and i2s devices and puts them in the uclass's
137 * private data for this device.
139 int sound_find_codec_i2s(struct udevice *dev);
141 #endif /* __SOUND__H__ */