summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandor Yu <Sandor.yu@nxp.com>2018-11-16 16:26:44 +0800
committerBryan O'Donoghue <bryan.odonoghue@linaro.org>2019-05-01 17:43:10 +0100
commitb5a71cf3c1363fdede96883da579dfa54d0e3b14 (patch)
treedf4afab95d268959d3443b7ba04d2f65751ddee3
parent7d0d71521a1dddb0c9f52d183764a3fc807bb201 (diff)
MLK-20391: v4l2: hdmi rx: Add hdmi cable plugin status check
Added hdmi cable plugin status check in v4l2 api function. Signed-off-by: Sandor Yu <Sandor.yu@nxp.com> (cherry picked from commit 88613061e5f9bbe4ac45ac1064003275aec31abb)
-rw-r--r--drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c24
-rw-r--r--drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.h1
2 files changed, 23 insertions, 2 deletions
diff --git a/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c b/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c
index 449f10f2ec92..43cee8612a9a 100644
--- a/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c
+++ b/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.c
@@ -292,6 +292,11 @@ static int mxc_hdmi_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
struct mxc_hdmi_rx_dev *hdmi_rx = imx_sd_to_hdmi(sd);
int ret = 0;
+ if (hdmi_rx->cable_plugin == false) {
+ dev_warn(&hdmi_rx->pdev->dev, "No Cable Connected!\n");
+ return -EINVAL;
+ }
+
switch (a->type) {
/* This is the only case currently handled. */
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -327,6 +332,11 @@ static int mxc_hdmi_s_stream(struct v4l2_subdev *sd, int enable)
u32 val;
dev_dbg(&hdmi_rx->pdev->dev, "%s\n", __func__);
+ if (hdmi_rx->cable_plugin == false) {
+ dev_warn(&hdmi_rx->pdev->dev, "No Cable Connected!\n");
+ return -EINVAL;
+ }
+
mxc_hdmi_pixel_link_encoder(hdmi_rx);
if (enable) {
@@ -375,7 +385,7 @@ static int mxc_hdmi_enum_framesizes(struct v4l2_subdev *sd,
{
struct mxc_hdmi_rx_dev *hdmi_rx = imx_sd_to_hdmi(sd);
- if (fse->index > 1)
+ if (fse->index > 1 || hdmi_rx->cable_plugin == false)
return -EINVAL;
fse->min_width = hdmi_rx->timings->timings.bt.width;
@@ -426,6 +436,11 @@ static int mxc_hdmi_get_format(struct v4l2_subdev *sd,
struct mxc_hdmi_rx_dev *hdmi_rx = imx_sd_to_hdmi(sd);
struct v4l2_mbus_framefmt *mbusformat = &sdformat->format;
+ if (hdmi_rx->cable_plugin == false) {
+ dev_warn(&hdmi_rx->pdev->dev, "No Cable Connected!\n");
+ return -EINVAL;
+ }
+
if (sdformat->pad != MXC_HDMI_RX_PAD_SOURCE)
return -EINVAL;
@@ -728,6 +743,7 @@ static void hpd5v_work_func(struct work_struct *work)
enable_irq(hdmi_rx->irq[HPD5V_IRQ_OUT]);
sprintf(event_string, "EVENT=hdmirxin");
kobject_uevent_env(&hdmi_rx->pdev->dev.kobj, KOBJ_CHANGE, envp);
+ hdmi_rx->cable_plugin = true;
#ifdef CONFIG_IMX_HDP_CEC
if (hdmi_rx->is_cec) {
mxc_hdmi_cec_init(hdmi_rx);
@@ -747,6 +763,7 @@ static void hpd5v_work_func(struct work_struct *work)
kobject_uevent_env(&hdmi_rx->pdev->dev.kobj, KOBJ_CHANGE, envp);
enable_irq(hdmi_rx->irq[HPD5V_IRQ_IN]);
CDN_API_MainControl_blocking(&hdmi_rx->state, 0, &sts);
+ hdmi_rx->cable_plugin = false;
} else
pr_warn("HDMI RX Cable State unknow\n");
@@ -876,8 +893,10 @@ static int mxc_hdmi_probe(struct platform_device *pdev)
goto failed;
}
/* Cable Disconnedted, enable Plug in IRQ */
- if (hpd == 0)
+ if (hpd == 0) {
enable_irq(hdmi_rx->irq[HPD5V_IRQ_IN]);
+ hdmi_rx->cable_plugin = false;
+ }
}
if (hdmi_rx->irq[HPD5V_IRQ_OUT] > 0) {
irq_set_status_flags(hdmi_rx->irq[HPD5V_IRQ_OUT], IRQ_NOAUTOEN);
@@ -894,6 +913,7 @@ static int mxc_hdmi_probe(struct platform_device *pdev)
hdmirx_startup(&hdmi_rx->state);
/* Cable Connected, enable Plug out IRQ */
enable_irq(hdmi_rx->irq[HPD5V_IRQ_OUT]);
+ hdmi_rx->cable_plugin = true;
}
}
diff --git a/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.h b/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.h
index 11afb99a74d5..5541361b608d 100644
--- a/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.h
+++ b/drivers/media/platform/imx8/hdmi/mxc-hdmi-rx.h
@@ -121,6 +121,7 @@ struct mxc_hdmi_rx_dev {
u8 hdmi_vic;
u8 pixel_encoding;
u8 color_depth;
+ bool cable_plugin;
u8 is_cec;
struct imx_cec_dev cec;