*/
int sandbox_get_sound_active(struct udevice *dev);
+/**
+ * sandbox_get_sound_count() - Read back the count of the sound data so far
+ *
+ * This data is provided to the sandbox driver by the sound play() method.
+ *
+ * @dev: Device to check
+ * Return: count of audio data
+ */
+int sandbox_get_sound_count(struct udevice *dev);
+
/**
* sandbox_get_sound_sum() - Read back the sum of the sound data so far
*
struct sandbox_sound_priv {
int setup_called; /* Incremented when setup() method is called */
bool active; /* TX data is being sent */
+ int count; /* Use to count the provided audio data */
int sum; /* Use to sum the provided audio data */
bool allow_beep; /* true to allow the start_beep() interface */
int frequency_hz; /* Beep frequency if active, else 0 */
return priv->active;
}
+int sandbox_get_sound_count(struct udevice *dev)
+{
+ struct sandbox_sound_priv *priv = dev_get_priv(dev);
+
+ return priv->count;
+}
+
int sandbox_get_sound_sum(struct udevice *dev)
{
struct sandbox_sound_priv *priv = dev_get_priv(dev);
for (i = 0; i < data_size; i++)
priv->sum += ((uint8_t *)data)[i];
+ priv->count += data_size;
return i2s_tx_data(uc_priv->i2s, data, data_size);
}
ut_asserteq(0, sandbox_get_setup_called(dev));
ut_assertok(sound_beep(dev, 1, 100));
+ ut_asserteq(48, sandbox_get_sound_count(dev));
ut_asserteq(4560, sandbox_get_sound_sum(dev));
ut_assertok(sound_beep(dev, 1, 100));
+ ut_asserteq(96, sandbox_get_sound_count(dev));
+ ut_asserteq(9120, sandbox_get_sound_sum(dev));
+ ut_assertok(sound_beep(dev, 1, -100));
+ ut_asserteq(144, sandbox_get_sound_count(dev));
+ ut_asserteq(9120, sandbox_get_sound_sum(dev));
+ ut_assertok(sound_beep(dev, 1, 0));
+ ut_asserteq(192, sandbox_get_sound_count(dev));
+ ut_asserteq(9120, sandbox_get_sound_sum(dev));
+ ut_assertok(sound_beep(dev, 1, INT_MAX));
+ ut_asserteq(240, sandbox_get_sound_count(dev));
ut_asserteq(9120, sandbox_get_sound_sum(dev));
ut_asserteq(false, sandbox_get_sound_active(dev));