Commit a3a2a21a authored by Mark Brown's avatar Mark Brown

(Re)enable DP/HDMI audio for RK3399 Gru

Merge series from Brian Norris <briannorris@chromium.org>:

This series fixes DP/HDMI audio for RK3399 Gru systems.

First, there was a regression with the switch to SPDIF. Patch 1 can be
taken separately as a regression fix if desired. But it's not quite so
useful (at least on Chrome OS systems) without the second part.

Second, jack detection was never upstreamed, because the hdmi-codec
dependencies were still being worked out when this platform was first
supported.

base-commit: e783362e
parents 73d4c313 6a8bc4b6
...@@ -586,6 +586,13 @@ static bool cdn_dp_check_link_status(struct cdn_dp_device *dp) ...@@ -586,6 +586,13 @@ static bool cdn_dp_check_link_status(struct cdn_dp_device *dp)
return drm_dp_channel_eq_ok(link_status, min(port->lanes, sink_lanes)); return drm_dp_channel_eq_ok(link_status, min(port->lanes, sink_lanes));
} }
static void cdn_dp_audio_handle_plugged_change(struct cdn_dp_device *dp,
bool plugged)
{
if (dp->codec_dev)
dp->plugged_cb(dp->codec_dev, plugged);
}
static void cdn_dp_encoder_enable(struct drm_encoder *encoder) static void cdn_dp_encoder_enable(struct drm_encoder *encoder)
{ {
struct cdn_dp_device *dp = encoder_to_dp(encoder); struct cdn_dp_device *dp = encoder_to_dp(encoder);
...@@ -641,6 +648,9 @@ static void cdn_dp_encoder_enable(struct drm_encoder *encoder) ...@@ -641,6 +648,9 @@ static void cdn_dp_encoder_enable(struct drm_encoder *encoder)
DRM_DEV_ERROR(dp->dev, "Failed to valid video %d\n", ret); DRM_DEV_ERROR(dp->dev, "Failed to valid video %d\n", ret);
goto out; goto out;
} }
cdn_dp_audio_handle_plugged_change(dp, true);
out: out:
mutex_unlock(&dp->lock); mutex_unlock(&dp->lock);
} }
...@@ -651,6 +661,8 @@ static void cdn_dp_encoder_disable(struct drm_encoder *encoder) ...@@ -651,6 +661,8 @@ static void cdn_dp_encoder_disable(struct drm_encoder *encoder)
int ret; int ret;
mutex_lock(&dp->lock); mutex_lock(&dp->lock);
cdn_dp_audio_handle_plugged_change(dp, false);
if (dp->active) { if (dp->active) {
ret = cdn_dp_disable(dp); ret = cdn_dp_disable(dp);
if (ret) { if (ret) {
...@@ -846,11 +858,27 @@ static int cdn_dp_audio_get_eld(struct device *dev, void *data, ...@@ -846,11 +858,27 @@ static int cdn_dp_audio_get_eld(struct device *dev, void *data,
return 0; return 0;
} }
static int cdn_dp_audio_hook_plugged_cb(struct device *dev, void *data,
hdmi_codec_plugged_cb fn,
struct device *codec_dev)
{
struct cdn_dp_device *dp = dev_get_drvdata(dev);
mutex_lock(&dp->lock);
dp->plugged_cb = fn;
dp->codec_dev = codec_dev;
cdn_dp_audio_handle_plugged_change(dp, dp->connected);
mutex_unlock(&dp->lock);
return 0;
}
static const struct hdmi_codec_ops audio_codec_ops = { static const struct hdmi_codec_ops audio_codec_ops = {
.hw_params = cdn_dp_audio_hw_params, .hw_params = cdn_dp_audio_hw_params,
.audio_shutdown = cdn_dp_audio_shutdown, .audio_shutdown = cdn_dp_audio_shutdown,
.mute_stream = cdn_dp_audio_mute_stream, .mute_stream = cdn_dp_audio_mute_stream,
.get_eld = cdn_dp_audio_get_eld, .get_eld = cdn_dp_audio_get_eld,
.hook_plugged_cb = cdn_dp_audio_hook_plugged_cb,
.no_capture_mute = 1, .no_capture_mute = 1,
}; };
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <drm/drm_dp_helper.h> #include <drm/drm_dp_helper.h>
#include <drm/drm_panel.h> #include <drm/drm_panel.h>
#include <drm/drm_probe_helper.h> #include <drm/drm_probe_helper.h>
#include <sound/hdmi-codec.h>
#include "rockchip_drm_drv.h" #include "rockchip_drm_drv.h"
...@@ -101,5 +102,8 @@ struct cdn_dp_device { ...@@ -101,5 +102,8 @@ struct cdn_dp_device {
u8 dpcd[DP_RECEIVER_CAP_SIZE]; u8 dpcd[DP_RECEIVER_CAP_SIZE];
bool sink_has_audio; bool sink_has_audio;
hdmi_codec_plugged_cb plugged_cb;
struct device *codec_dev;
}; };
#endif /* _CDN_DP_CORE_H */ #endif /* _CDN_DP_CORE_H */
...@@ -164,6 +164,25 @@ static int rockchip_sound_da7219_hw_params(struct snd_pcm_substream *substream, ...@@ -164,6 +164,25 @@ static int rockchip_sound_da7219_hw_params(struct snd_pcm_substream *substream,
return 0; return 0;
} }
static struct snd_soc_jack cdn_dp_card_jack;
static int rockchip_sound_cdndp_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
struct snd_soc_card *card = rtd->card;
int ret;
/* Enable jack detection. */
ret = snd_soc_card_jack_new(card, "DP Jack", SND_JACK_LINEOUT,
&cdn_dp_card_jack, NULL, 0);
if (ret) {
dev_err(card->dev, "Can't create DP Jack %d\n", ret);
return ret;
}
return snd_soc_component_set_jack(component, &cdn_dp_card_jack, NULL);
}
static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd) static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
...@@ -315,6 +334,7 @@ static const struct snd_soc_dai_link rockchip_dais[] = { ...@@ -315,6 +334,7 @@ static const struct snd_soc_dai_link rockchip_dais[] = {
[DAILINK_CDNDP] = { [DAILINK_CDNDP] = {
.name = "DP", .name = "DP",
.stream_name = "DP PCM", .stream_name = "DP PCM",
.init = rockchip_sound_cdndp_init,
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS, SND_SOC_DAIFMT_CBS_CFS,
SND_SOC_DAILINK_REG(cdndp), SND_SOC_DAILINK_REG(cdndp),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment