diff options
Diffstat (limited to 'drivers/media/cec/core/cec-notifier.c')
| -rw-r--r-- | drivers/media/cec/core/cec-notifier.c | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/drivers/media/cec/core/cec-notifier.c b/drivers/media/cec/core/cec-notifier.c index 517e0035fc99..1fed0b1c71e9 100644 --- a/drivers/media/cec/core/cec-notifier.c +++ b/drivers/media/cec/core/cec-notifier.c @@ -7,8 +7,10 @@ */ #include <linux/export.h> +#include <linux/platform_device.h> #include <linux/string.h> #include <linux/slab.h> +#include <linux/i2c.h> #include <linux/list.h> #include <linux/kref.h> #include <linux/of_platform.h> @@ -116,7 +118,8 @@ cec_notifier_conn_register(struct device *hdmi_dev, const char *port_name, else memset(&n->conn_info, 0, sizeof(n->conn_info)); if (n->cec_adap) { - cec_phys_addr_invalidate(n->cec_adap); + if (!n->cec_adap->adap_controls_phys_addr) + cec_phys_addr_invalidate(n->cec_adap); cec_s_conn_info(n->cec_adap, conn_info); } mutex_unlock(&n->lock); @@ -133,7 +136,8 @@ void cec_notifier_conn_unregister(struct cec_notifier *n) memset(&n->conn_info, 0, sizeof(n->conn_info)); n->phys_addr = CEC_PHYS_ADDR_INVALID; if (n->cec_adap) { - cec_phys_addr_invalidate(n->cec_adap); + if (!n->cec_adap->adap_controls_phys_addr) + cec_phys_addr_invalidate(n->cec_adap); cec_s_conn_info(n->cec_adap, NULL); } mutex_unlock(&n->lock); @@ -158,7 +162,8 @@ cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *port_name, n->cec_adap = adap; adap->conn_info = n->conn_info; adap->notifier = n; - cec_s_phys_addr(adap, n->phys_addr, false); + if (!adap->adap_controls_phys_addr) + cec_s_phys_addr(adap, n->phys_addr, false); mutex_unlock(&n->lock); return n; } @@ -185,12 +190,17 @@ void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa) mutex_lock(&n->lock); n->phys_addr = pa; - if (n->cec_adap) + if (n->cec_adap && !n->cec_adap->adap_controls_phys_addr) cec_s_phys_addr(n->cec_adap, n->phys_addr, false); mutex_unlock(&n->lock); } EXPORT_SYMBOL_GPL(cec_notifier_set_phys_addr); +/* + * Note: In the drm subsystem, prefer calling (if possible): + * + * cec_notifier_set_phys_addr(n, connector->display_info.source_physical_address); + */ void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, const struct edid *edid) { @@ -218,19 +228,29 @@ struct device *cec_notifier_parse_hdmi_phandle(struct device *dev) dev_err(dev, "Failed to find HDMI node in device tree\n"); return ERR_PTR(-ENODEV); } + hdmi_pdev = of_find_device_by_node(np); - of_node_put(np); - if (hdmi_pdev) { + if (hdmi_pdev) hdmi_dev = &hdmi_pdev->dev; - /* - * Note that the device struct is only used as a key into the - * cec_notifiers list, it is never actually accessed. - * So we decrement the reference here so we don't leak - * memory. - */ - put_device(hdmi_dev); - return hdmi_dev; +#if IS_REACHABLE(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; } - return ERR_PTR(-EPROBE_DEFER); +#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 + * cec_notifiers list, it is never actually accessed. + * So we decrement the reference here so we don't leak + * memory. + */ + put_device(hdmi_dev); + return hdmi_dev; } EXPORT_SYMBOL_GPL(cec_notifier_parse_hdmi_phandle); |
