Skip to content

Commit

Permalink
dm: sound: Complete migration to driver model
Browse files Browse the repository at this point in the history
All users of sound are converted to use driver model. Drop the old code
and the CONFIG_DM_SOUND option.

Signed-off-by: Simon Glass <[email protected]>
  • Loading branch information
sjg20 committed Dec 13, 2018
1 parent 1e224fe commit f2b25c9
Show file tree
Hide file tree
Showing 18 changed files with 16 additions and 475 deletions.
1 change: 0 additions & 1 deletion arch/sandbox/cpu/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <unistd.h>
#include <linux/input.h>
#include <SDL/SDL.h>
#include <sound.h>
#include <asm/state.h>

enum {
Expand Down
21 changes: 9 additions & 12 deletions arch/sandbox/include/asm/sdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ int sandbox_sdl_scan_keys(int key[], int max_keys);
int sandbox_sdl_key_pressed(int keycode);

/**
* sandbox_sdl_sound_start() - start playing a sound
* sandbox_sdl_sound_play() - Play a sound
*
* @frequency: Frequency of sounds in Hertz
* @return 0 if OK, -ENODEV if no sound is available
* @data: Data to play (typically 16-bit)
* @count: Number of bytes in data
*/
int sandbox_sdl_sound_start(uint frequency);
int sandbox_sdl_sound_play(const void *data, uint count);

/**
* sandbox_sdl_sound_stop() - stop playing a sound
Expand All @@ -68,14 +68,6 @@ int sandbox_sdl_sound_start(uint frequency);
*/
int sandbox_sdl_sound_stop(void);

/**
* sandbox_sdl_sound_play() - Play a sound
*
* @data: Data to play (typically 16-bit)
* @count: Number of bytes in data
*/
int sandbox_sdl_sound_play(const void *data, uint count);

/**
* sandbox_sdl_sound_init() - set up the sound system
*
Expand Down Expand Up @@ -110,6 +102,11 @@ static inline int sandbox_sdl_sound_start(uint frequency)
return -ENODEV;
}

int sandbox_sdl_sound_play(const void *data, uint count)
{
return -ENODEV;
}

static inline int sandbox_sdl_sound_stop(void)
{
return -ENODEV;
Expand Down
13 changes: 0 additions & 13 deletions arch/sandbox/include/asm/sound.h

This file was deleted.

12 changes: 0 additions & 12 deletions cmd/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@ DECLARE_GLOBAL_DATA_PTR;
/* Initilaise sound subsystem */
static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
#ifdef CONFIG_DM_SOUND
struct udevice *dev;
#endif
int ret;

#ifdef CONFIG_DM_SOUND
ret = uclass_first_device_err(UCLASS_SOUND, &dev);
if (!ret)
ret = sound_setup(dev);
#else
ret = sound_init(gd->fdt_blob);
#endif
if (ret) {
printf("Initialise Audio driver failed (ret=%d)\n", ret);
return CMD_RET_FAILURE;
Expand All @@ -38,9 +32,7 @@ static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
/* play sound from buffer */
static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
#ifdef CONFIG_DM_SOUND
struct udevice *dev;
#endif
int ret = 0;
int msec = 1000;
int freq = 400;
Expand All @@ -50,13 +42,9 @@ static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
if (argc > 2)
freq = simple_strtoul(argv[2], NULL, 10);

#ifdef CONFIG_DM_SOUND
ret = uclass_first_device_err(UCLASS_SOUND, &dev);
if (!ret)
ret = sound_beep(dev, msec, freq);
#else
ret = sound_play(msec, freq);
#endif
if (ret) {
printf("Sound device failed to play (err=%d)\n", ret);
return CMD_RET_FAILURE;
Expand Down
1 change: 0 additions & 1 deletion configs/arndale_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ CONFIG_MMC_SDHCI_S5P=y
CONFIG_SMC911X=y
CONFIG_SMC911X_BASE=0x5000000
CONFIG_SOUND=y
CONFIG_DM_SOUND=y
CONFIG_I2S=y
CONFIG_I2S_SAMSUNG=y
CONFIG_SOUND_MAX98095=y
Expand Down
1 change: 0 additions & 1 deletion configs/peach-pi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ CONFIG_REGULATOR_TPS65090=y
CONFIG_DM_PWM=y
CONFIG_PWM_EXYNOS=y
CONFIG_SOUND=y
CONFIG_DM_SOUND=y
CONFIG_I2S=y
CONFIG_I2S_SAMSUNG=y
CONFIG_SOUND_MAX98090=y
Expand Down
1 change: 0 additions & 1 deletion configs/peach-pit_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ CONFIG_REGULATOR_TPS65090=y
CONFIG_DM_PWM=y
CONFIG_PWM_EXYNOS=y
CONFIG_SOUND=y
CONFIG_DM_SOUND=y
CONFIG_I2S=y
CONFIG_I2S_SAMSUNG=y
CONFIG_SOUND_MAX98090=y
Expand Down
1 change: 0 additions & 1 deletion configs/smdk5250_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ CONFIG_DM_PMIC_MAX77686=y
CONFIG_DM_REGULATOR=y
CONFIG_DM_REGULATOR_MAX77686=y
CONFIG_SOUND=y
CONFIG_DM_SOUND=y
CONFIG_I2S=y
CONFIG_I2S_SAMSUNG=y
CONFIG_SOUND_MAX98095=y
Expand Down
1 change: 0 additions & 1 deletion configs/snow_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ CONFIG_DM_PWM=y
CONFIG_PWM_EXYNOS=y
CONFIG_DEBUG_UART_S5P=y
CONFIG_SOUND=y
CONFIG_DM_SOUND=y
CONFIG_I2S=y
CONFIG_I2S_SAMSUNG=y
CONFIG_SOUND_MAX98095=y
Expand Down
1 change: 0 additions & 1 deletion configs/spring_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ CONFIG_DM_PWM=y
CONFIG_PWM_EXYNOS=y
CONFIG_DEBUG_UART_S5P=y
CONFIG_SOUND=y
CONFIG_DM_SOUND=y
CONFIG_I2S=y
CONFIG_I2S_SAMSUNG=y
CONFIG_SOUND_MAX98095=y
Expand Down
6 changes: 0 additions & 6 deletions drivers/sound/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ config SOUND
audio codecs are called from the sound-i2s code. This could be
converted to driver model.

config DM_SOUND
bool "Use driver model for sound"
help
Enable this option to use driver model for sound devices. This is a
migration option and will be removed.

config I2S
bool "Enable I2S support"
depends on SOUND
Expand Down
10 changes: 3 additions & 7 deletions drivers/sound/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
# R. Chandrasekar <[email protected]>

obj-$(CONFIG_SOUND) += sound.o
obj-$(CONFIG_DM_SOUND) += codec-uclass.o
obj-$(CONFIG_DM_SOUND) += i2s-uclass.o
obj-$(CONFIG_DM_SOUND) += sound-uclass.o
obj-$(CONFIG_SOUND) += codec-uclass.o
obj-$(CONFIG_SOUND) += i2s-uclass.o
obj-$(CONFIG_SOUND) += sound-uclass.o
obj-$(CONFIG_I2S_SAMSUNG) += samsung-i2s.o
obj-$(CONFIG_SOUND_SANDBOX) += sandbox.o
ifdef CONFIG_DM_SOUND
obj-$(CONFIG_I2S_SAMSUNG) += samsung_sound.o
else
obj-$(CONFIG_I2S) += sound-i2s.o
endif
obj-$(CONFIG_SOUND_WM8994) += wm8994.o
obj-$(CONFIG_SOUND_MAX98090) += max98090.o maxim_codec.o
obj-$(CONFIG_SOUND_MAX98095) += max98095.o maxim_codec.o
78 changes: 0 additions & 78 deletions drivers/sound/max98095.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,84 +432,6 @@ static int max98095_do_init(struct maxim_priv *priv,
return ret;
}

#ifndef CONFIG_DM_SOUND
static int get_max98095_codec_values(struct sound_codec_info *pcodec_info,
const void *blob)
{
int error = 0;
enum fdt_compat_id compat;
int node;
int parent;

/* Get the node from FDT for codec */
node = fdtdec_next_compatible(blob, 0, COMPAT_MAXIM_98095_CODEC);
if (node <= 0) {
debug("EXYNOS_SOUND: No node for codec in device tree\n");
debug("node = %d\n", node);
return -1;
}

parent = fdt_parent_offset(blob, node);
if (parent < 0) {
debug("%s: Cannot find node parent\n", __func__);
return -1;
}

compat = fdtdec_lookup(blob, parent);
switch (compat) {
case COMPAT_SAMSUNG_S3C2440_I2C:
pcodec_info->i2c_bus = i2c_get_bus_num_fdt(parent);
error |= pcodec_info->i2c_bus;
debug("i2c bus = %d\n", pcodec_info->i2c_bus);
pcodec_info->i2c_dev_addr = fdtdec_get_int(blob, node,
"reg", 0);
error |= pcodec_info->i2c_dev_addr;
debug("i2c dev addr = %x\n", pcodec_info->i2c_dev_addr);
break;
default:
debug("%s: Unknown compat id %d\n", __func__, compat);
return -1;
}
if (error == -1) {
debug("fail to get max98095 codec node properties\n");
return -1;
}

return 0;
}

/* max98095 Device Initialisation */
int max98095_init(const void *blob, enum en_max_audio_interface aif_id,
int sampling_rate, int mclk_freq,
int bits_per_sample)
{
int ret;
int old_bus = i2c_get_bus_num();
struct sound_codec_info pcodec_info;
struct max98095_priv max98095_info;

if (get_max98095_codec_values(&pcodec_info, blob) < 0) {
debug("FDT Codec values failed\n");
return -1;
}

i2c_set_bus_num(pcodec_info.i2c_bus);

max98095_info.i2c_addr = pcodec_info.i2c_dev_addr;
ret = max98095_device_init(&max98095_info);
if (ret < 0) {
debug("%s: max98095 codec chip init failed\n", __func__);
return ret;
}

ret = max98095_do_init(&max98095_info, aif_id, sampling_rate, mclk_freq,
bits_per_sample);
i2c_set_bus_num(old_bus);

return ret;
}
#endif

static int max98095_set_params(struct udevice *dev, int interface, int rate,
int mclk_freq, int bits_per_sample,
uint channels)
Expand Down
19 changes: 1 addition & 18 deletions drivers/sound/sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <dm.h>
#include <i2s.h>
#include <sound.h>
#include <asm/sound.h>
#include <asm/sdl.h>

struct sandbox_codec_priv {
Expand All @@ -28,22 +27,6 @@ struct sandbox_sound_priv {
int sum; /* Use to sum the provided audio data */
};

#ifndef CONFIG_DM_SOUND
int sound_play(uint32_t msec, uint32_t frequency)
{
sandbox_sdl_sound_start(frequency);
mdelay(msec);
sandbox_sdl_sound_stop();

return 0;
}
#endif /* CONFIG_DM_SOUND */

int sound_init(const void *blob)
{
return sandbox_sdl_sound_init();
}

void sandbox_get_codec_params(struct udevice *dev, int *interfacep, int *ratep,
int *mclk_freqp, int *bits_per_samplep,
uint *channelsp)
Expand Down Expand Up @@ -102,7 +85,7 @@ static int sandbox_i2s_tx_data(struct udevice *dev, void *data,
for (i = 0; i < data_size; i++)
priv->sum += ((uint8_t *)data)[i];

return 0;
return sandbox_sdl_sound_play(data, data_size);
}

static int sandbox_i2s_probe(struct udevice *dev)
Expand Down
Loading

0 comments on commit f2b25c9

Please sign in to comment.