summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoy Cho <joy.cho@hardkernel.com>2020-12-02 08:40:56 +0300
committerJoy Cho <joy.cho@hardkernel.com>2020-12-02 10:36:20 +0300
commit9fb75d57d8801fe451eb6b6e7e79564bd1941be7 (patch)
treeb8d394b8c9850a11e0ff6e9deebeb5bac6f1a264
parent2efc5159499a0bfd9dfc6a116394fb4f85dfa551 (diff)
downloadu-boot-9fb75d57d8801fe451eb6b6e7e79564bd1941be7.tar.xz
sound: Add playback path api of rockchip sound
Change-Id: I2603f88e2c437d92e8b15c81a3a446e73c3e2e5b
-rw-r--r--cmd/sound.c18
-rw-r--r--drivers/sound/rk817_codec.c13
-rw-r--r--drivers/sound/rk817_codec.h2
-rw-r--r--drivers/sound/rockchip-sound.c13
-rw-r--r--include/sound.h27
5 files changed, 73 insertions, 0 deletions
diff --git a/cmd/sound.c b/cmd/sound.c
index f5dd8bcf26..1833aaa0d4 100644
--- a/cmd/sound.c
+++ b/cmd/sound.c
@@ -47,9 +47,26 @@ static int do_play(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
return 0;
}
+/* set playback path */
+static int do_path(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ if (!strcmp(argv[1], "spk"))
+ sound_path(SPK_PATH);
+ else if (!strcmp(argv[1], "hp"))
+ sound_path(HP_PATH);
+ else
+ return CMD_RET_USAGE;
+
+ return 0;
+}
+
static cmd_tbl_t cmd_sound_sub[] = {
U_BOOT_CMD_MKENT(init, 0, 1, do_init, "", ""),
U_BOOT_CMD_MKENT(play, 2, 1, do_play, "", ""),
+ U_BOOT_CMD_MKENT(path, 1, 1, do_path, "", ""),
};
/* process sound command */
@@ -77,4 +94,5 @@ U_BOOT_CMD(
"sound sub-system",
"init - initialise the sound driver\n"
"sound play [len] [freq] - play a sound for len ms at freq hz\n"
+ "path [path] - set playback, use spk or hp\n"
);
diff --git a/drivers/sound/rk817_codec.c b/drivers/sound/rk817_codec.c
index b753d7e828..56e79b9d07 100644
--- a/drivers/sound/rk817_codec.c
+++ b/drivers/sound/rk817_codec.c
@@ -310,15 +310,28 @@ static int rk817_startup(struct udevice *dev)
{
struct rk817_codec_priv *rk817 = dev_get_priv(dev);
+#ifndef CONFIG_PLATFORM_ODROID_GOADV
rk817_playback_path_put(rk817, SPK_HP);
+#endif
rk817_digital_mute(rk817, 0);
return 0;
}
+static int rk817_set_path(struct udevice *dev, unsigned path)
+{
+ struct rk817_codec_priv *rk817 = dev_get_priv(dev);
+
+ DBG("[%s] path %d\n", __func__, path);
+ rk817_playback_path_put(rk817, path);
+
+ return 0;
+}
+
static const struct snd_soc_dai_ops rk817_codec_ops = {
.hw_params = rk817_hw_params,
.startup = rk817_startup,
+ .set_path = rk817_set_path,
};
static int rk817_codec_probe(struct udevice *dev)
diff --git a/drivers/sound/rk817_codec.h b/drivers/sound/rk817_codec.h
index d4956a1e5c..2860e78576 100644
--- a/drivers/sound/rk817_codec.h
+++ b/drivers/sound/rk817_codec.h
@@ -168,6 +168,7 @@ enum {
RK817_STEREO,
};
+#ifndef CONFIG_PLATFORM_ODROID_GOADV
enum {
OFF,
RCV,
@@ -181,6 +182,7 @@ enum {
RING_HP_NO_MIC,
RING_SPK_HP,
};
+#endif
enum {
MIC_OFF,
diff --git a/drivers/sound/rockchip-sound.c b/drivers/sound/rockchip-sound.c
index 1b0721936c..394c058ad1 100644
--- a/drivers/sound/rockchip-sound.c
+++ b/drivers/sound/rockchip-sound.c
@@ -138,3 +138,16 @@ int sound_play(u32 msec, u32 frequency)
return ret;
}
+
+#ifdef CONFIG_PLATFORM_ODROID_GOADV
+int sound_path(u32 path)
+{
+ const struct snd_soc_dai_ops *ops = dev_get_driver_ops(codec_dev);
+
+ if (!ops || !ops->set_path)
+ return -ENOTSUPP;
+
+ return ops->set_path(codec_dev, path);
+
+}
+#endif
diff --git a/include/sound.h b/include/sound.h
index 73c1daaf3e..9feae06663 100644
--- a/include/sound.h
+++ b/include/sound.h
@@ -53,6 +53,30 @@ int sound_init(const void *blob);
*/
int sound_play(uint32_t msec, uint32_t frequency);
+#ifdef CONFIG_PLATFORM_ODROID_GOADV
+enum {
+ OFF,
+ RCV,
+ SPK_PATH,
+ HP_PATH,
+ HP_NO_MIC,
+ BT,
+ SPK_HP,
+ RING_SPK,
+ RING_HP,
+ RING_HP_NO_MIC,
+ RING_SPK_HP,
+};
+
+/*
+ * Set playback path
+ * @param path
+ *
+ * @return int 0 for success, -1 for error
+ */
+int sound_path(uint32_t path);
+#endif
+
struct snd_soc_dai_ops {
int (*hw_params)(struct udevice *dev, unsigned int samplerate,
unsigned int fmt, unsigned int channels);
@@ -61,6 +85,9 @@ struct snd_soc_dai_ops {
int (*transfer)(struct udevice *dev, unsigned int *data,
unsigned long data_size);
int (*set_sysclk)(struct udevice *dev, unsigned int freq);
+#ifdef CONFIG_PLATFORM_ODROID_GOADV
+ int (*set_path)(struct udevice *dev, unsigned int path);
+#endif
};
#endif /* __SOUND__H__ */