Commit 71bb1b99 authored by Johan Fjeldtvedt's avatar Johan Fjeldtvedt Committed by Mauro Carvalho Chehab

media: cec-notifier: also search for HDMI devices on I2C

Currently the cec_notifier_parse_hdmi_phandle function can only be used
if the HDMI device associated with the CEC device is a platform device.
Extend the function to cover I2C devices as well, as there do exist
some I2C HDMI devices which don't handle CEC internally and need an
external CEC adapter.

[hverkuil: add missing linux/i2c.h header]
[hverkuil: only attempt to find the i2c device if CONFIG_I2C is set]
Signed-off-by: default avatarJohan Fjeldtvedt <johfjeld@cisco.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 9c39be40
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/kref.h> #include <linux/kref.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
...@@ -221,10 +222,22 @@ struct device *cec_notifier_parse_hdmi_phandle(struct device *dev) ...@@ -221,10 +222,22 @@ struct device *cec_notifier_parse_hdmi_phandle(struct device *dev)
dev_err(dev, "Failed to find HDMI node in device tree\n"); dev_err(dev, "Failed to find HDMI node in device tree\n");
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
} }
hdmi_pdev = of_find_device_by_node(np); hdmi_pdev = of_find_device_by_node(np);
of_node_put(np); if (hdmi_pdev)
if (hdmi_pdev) {
hdmi_dev = &hdmi_pdev->dev; hdmi_dev = &hdmi_pdev->dev;
#if IS_ENABLED(CONFIG_I2C)
if (!hdmi_dev) {
struct i2c_client *hdmi_client = of_find_i2c_device_by_node(np);
if (hdmi_client)
hdmi_dev = &hdmi_client->dev;
}
#endif
of_node_put(np);
if (!hdmi_dev)
return ERR_PTR(-EPROBE_DEFER);
/* /*
* Note that the device struct is only used as a key into the * Note that the device struct is only used as a key into the
* cec_notifiers list, it is never actually accessed. * cec_notifiers list, it is never actually accessed.
...@@ -233,7 +246,5 @@ struct device *cec_notifier_parse_hdmi_phandle(struct device *dev) ...@@ -233,7 +246,5 @@ struct device *cec_notifier_parse_hdmi_phandle(struct device *dev)
*/ */
put_device(hdmi_dev); put_device(hdmi_dev);
return hdmi_dev; return hdmi_dev;
}
return ERR_PTR(-EPROBE_DEFER);
} }
EXPORT_SYMBOL_GPL(cec_notifier_parse_hdmi_phandle); EXPORT_SYMBOL_GPL(cec_notifier_parse_hdmi_phandle);
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