drm/rockchip: cdn-dp: Support HDMI codec plug-change callback
Some audio servers like to monitor a jack device (perhaps combined with EDID, for audio-presence info) to determine DP/HDMI audio presence. Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Link: https://lore.kernel.org/r/20220114150129.v2.2.I20d754a1228aa5c51a18c8eb15a2c60dec25b639@changeid Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
e783362eb5
commit
9da1467b49
|
@ -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));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
struct cdn_dp_device *dp = encoder_to_dp(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);
|
||||
goto out;
|
||||
}
|
||||
|
||||
cdn_dp_audio_handle_plugged_change(dp, true);
|
||||
|
||||
out:
|
||||
mutex_unlock(&dp->lock);
|
||||
}
|
||||
|
@ -651,6 +661,8 @@ static void cdn_dp_encoder_disable(struct drm_encoder *encoder)
|
|||
int ret;
|
||||
|
||||
mutex_lock(&dp->lock);
|
||||
cdn_dp_audio_handle_plugged_change(dp, false);
|
||||
|
||||
if (dp->active) {
|
||||
ret = cdn_dp_disable(dp);
|
||||
if (ret) {
|
||||
|
@ -846,11 +858,27 @@ static int cdn_dp_audio_get_eld(struct device *dev, void *data,
|
|||
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 = {
|
||||
.hw_params = cdn_dp_audio_hw_params,
|
||||
.audio_shutdown = cdn_dp_audio_shutdown,
|
||||
.mute_stream = cdn_dp_audio_mute_stream,
|
||||
.get_eld = cdn_dp_audio_get_eld,
|
||||
.hook_plugged_cb = cdn_dp_audio_hook_plugged_cb,
|
||||
.no_capture_mute = 1,
|
||||
};
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <drm/drm_dp_helper.h>
|
||||
#include <drm/drm_panel.h>
|
||||
#include <drm/drm_probe_helper.h>
|
||||
#include <sound/hdmi-codec.h>
|
||||
|
||||
#include "rockchip_drm_drv.h"
|
||||
|
||||
|
@ -101,5 +102,8 @@ struct cdn_dp_device {
|
|||
|
||||
u8 dpcd[DP_RECEIVER_CAP_SIZE];
|
||||
bool sink_has_audio;
|
||||
|
||||
hdmi_codec_plugged_cb plugged_cb;
|
||||
struct device *codec_dev;
|
||||
};
|
||||
#endif /* _CDN_DP_CORE_H */
|
||||
|
|
Loading…
Reference in New Issue