From a8de4e09e248548962210edbef3f39a93e99ea94 Mon Sep 17 00:00:00 2001 From: Shunhua Lan Date: Thu, 13 Oct 2022 12:21:53 +0000 Subject: [PATCH] media: rockchip: hdmirx: Add extcon support Signed-off-by: Shunhua Lan Change-Id: Ia19b8f7230af515b8dbc7bb953d03e8e5dbb1f7a --- .../platform/rockchip/hdmirx/rk_hdmirx.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/media/platform/rockchip/hdmirx/rk_hdmirx.c b/drivers/media/platform/rockchip/hdmirx/rk_hdmirx.c index 18b06d4dcb03..1c0705b2ae5d 100644 --- a/drivers/media/platform/rockchip/hdmirx/rk_hdmirx.c +++ b/drivers/media/platform/rockchip/hdmirx/rk_hdmirx.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -195,6 +196,7 @@ struct rk_hdmirx_dev { struct dentry *debugfs_dir; struct freq_qos_request min_sta_freq_req; struct hdmirx_audiostate audio_state; + struct extcon_dev *extcon; struct hdmirx_cec *cec; struct mutex stream_lock; struct mutex work_lock; @@ -245,6 +247,11 @@ struct rk_hdmirx_dev { spinlock_t rst_lock; }; +static const unsigned int hdmirx_extcon_cable[] = { + EXTCON_JACK_VIDEO_IN, + EXTCON_NONE, +}; + static bool tx_5v_power_present(struct rk_hdmirx_dev *hdmirx_dev); static void hdmirx_set_fmt(struct hdmirx_stream *stream, struct v4l2_pix_format_mplane *pixm, bool try); @@ -2672,12 +2679,14 @@ static void hdmirx_plugin(struct rk_hdmirx_dev *hdmirx_dev) } hdmirx_dma_config(hdmirx_dev); hdmirx_interrupts_setup(hdmirx_dev, true); + extcon_set_state_sync(hdmirx_dev->extcon, EXTCON_JACK_VIDEO_IN, true); hdmirx_audio_handle_plugged_change(hdmirx_dev, 1); } static void hdmirx_plugout(struct rk_hdmirx_dev *hdmirx_dev) { hdmirx_audio_handle_plugged_change(hdmirx_dev, 0); + extcon_set_state_sync(hdmirx_dev->extcon, EXTCON_JACK_VIDEO_IN, false); hdmirx_update_bits(hdmirx_dev, SCDC_CONFIG, POWERPROVIDED, 0); hdmirx_interrupts_setup(hdmirx_dev, false); hdmirx_hpd_ctrl(hdmirx_dev, false); @@ -4102,6 +4111,19 @@ static int hdmirx_probe(struct platform_device *pdev) if (ret) goto err_unreg_video_dev; + hdmirx_dev->extcon = devm_extcon_dev_allocate(dev, hdmirx_extcon_cable); + if (IS_ERR(hdmirx_dev->extcon)) { + ret = PTR_ERR(hdmirx_dev->extcon); + dev_err(&pdev->dev, "allocate extcon failed\n"); + goto err_unreg_video_dev; + } + + ret = devm_extcon_dev_register(dev, hdmirx_dev->extcon); + if (ret) { + dev_err(&pdev->dev, "failed to register extcon: %d\n", ret); + goto err_unreg_video_dev; + } + irq = gpiod_to_irq(hdmirx_dev->hdmirx_det_gpio); if (irq < 0) { dev_err(dev, "failed to get hdmirx-det gpio irq\n");