/* SPDX-License-Identifier: GPL-2.0-only */1/*2* cec-notifier.h - notify CEC drivers of physical address changes3*4* Copyright 2016 Russell King.5* Copyright 2016-2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.6*/78#ifndef LINUX_CEC_NOTIFIER_H9#define LINUX_CEC_NOTIFIER_H1011#include <linux/err.h>12#include <media/cec.h>1314struct device;15struct edid;16struct cec_adapter;17struct cec_notifier;1819#if IS_REACHABLE(CONFIG_CEC_CORE) && IS_ENABLED(CONFIG_CEC_NOTIFIER)2021/**22* cec_notifier_conn_register - find or create a new cec_notifier for the given23* HDMI device and connector tuple.24* @hdmi_dev: HDMI device that sends the events.25* @port_name: the connector name from which the event occurs. May be NULL26* if there is always only one HDMI connector created by the HDMI device.27* @conn_info: the connector info from which the event occurs (may be NULL)28*29* If a notifier for device @dev and connector @port_name already exists, then30* increase the refcount and return that notifier.31*32* If it doesn't exist, then allocate a new notifier struct and return a33* pointer to that new struct.34*35* Return NULL if the memory could not be allocated.36*/37struct cec_notifier *38cec_notifier_conn_register(struct device *hdmi_dev, const char *port_name,39const struct cec_connector_info *conn_info);4041/**42* cec_notifier_conn_unregister - decrease refcount and delete when the43* refcount reaches 0.44* @n: notifier. If NULL, then this function does nothing.45*/46void cec_notifier_conn_unregister(struct cec_notifier *n);4748/**49* cec_notifier_cec_adap_register - find or create a new cec_notifier for the50* given device.51* @hdmi_dev: HDMI device that sends the events.52* @port_name: the connector name from which the event occurs. May be NULL53* if there is always only one HDMI connector created by the HDMI device.54* @adap: the cec adapter that registered this notifier.55*56* If a notifier for device @dev and connector @port_name already exists, then57* increase the refcount and return that notifier.58*59* If it doesn't exist, then allocate a new notifier struct and return a60* pointer to that new struct.61*62* Return NULL if the memory could not be allocated.63*/64struct cec_notifier *65cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *port_name,66struct cec_adapter *adap);6768/**69* cec_notifier_cec_adap_unregister - decrease refcount and delete when the70* refcount reaches 0.71* @n: notifier. If NULL, then this function does nothing.72* @adap: the cec adapter that registered this notifier.73*/74void cec_notifier_cec_adap_unregister(struct cec_notifier *n,75struct cec_adapter *adap);7677/**78* cec_notifier_set_phys_addr - set a new physical address.79* @n: the CEC notifier80* @pa: the CEC physical address81*82* Set a new CEC physical address.83* Does nothing if @n == NULL.84*/85void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa);8687/**88* cec_notifier_set_phys_addr_from_edid - set parse the PA from the EDID.89* @n: the CEC notifier90* @edid: the struct edid pointer91*92* Parses the EDID to obtain the new CEC physical address and set it.93* Does nothing if @n == NULL.94*/95void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n,96const struct edid *edid);9798/**99* cec_notifier_parse_hdmi_phandle - find the hdmi device from "hdmi-phandle"100* @dev: the device with the "hdmi-phandle" device tree property101*102* Returns the device pointer referenced by the "hdmi-phandle" property.103* Note that the refcount of the returned device is not incremented.104* This device pointer is only used as a key value in the notifier105* list, but it is never accessed by the CEC driver.106*/107struct device *cec_notifier_parse_hdmi_phandle(struct device *dev);108109#else110111static inline struct cec_notifier *112cec_notifier_conn_register(struct device *hdmi_dev, const char *port_name,113const struct cec_connector_info *conn_info)114{115/* A non-NULL pointer is expected on success */116return (struct cec_notifier *)0xdeadfeed;117}118119static inline void cec_notifier_conn_unregister(struct cec_notifier *n)120{121}122123static inline struct cec_notifier *124cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *port_name,125struct cec_adapter *adap)126{127/* A non-NULL pointer is expected on success */128return (struct cec_notifier *)0xdeadfeed;129}130131static inline void cec_notifier_cec_adap_unregister(struct cec_notifier *n,132struct cec_adapter *adap)133{134}135136static inline void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa)137{138}139140static inline void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n,141const struct edid *edid)142{143}144145static inline struct device *cec_notifier_parse_hdmi_phandle(struct device *dev)146{147return ERR_PTR(-ENODEV);148}149150#endif151152/**153* cec_notifier_phys_addr_invalidate() - set the physical address to INVALID154*155* @n: the CEC notifier156*157* This is a simple helper function to invalidate the physical158* address. Does nothing if @n == NULL.159*/160static inline void cec_notifier_phys_addr_invalidate(struct cec_notifier *n)161{162cec_notifier_set_phys_addr(n, CEC_PHYS_ADDR_INVALID);163}164165#endif166167168