2 * cec-notifier.h - notify CEC drivers of physical address changes
4 * Copyright 2016 Russell King <rmk+kernel@arm.linux.org.uk>
5 * Copyright 2016-2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
7 * This program is free software; you may redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
12 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
15 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
16 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 #ifndef LINUX_CEC_NOTIFIER_H
22 #define LINUX_CEC_NOTIFIER_H
24 #include <linux/types.h>
25 #include <media/cec.h>
32 #if IS_REACHABLE(CONFIG_CEC_CORE) && IS_ENABLED(CONFIG_CEC_NOTIFIER)
35 * cec_notifier_get - find or create a new cec_notifier for the given device.
36 * @dev: device that sends the events.
38 * If a notifier for device @dev already exists, then increase the refcount
39 * and return that notifier.
41 * If it doesn't exist, then allocate a new notifier struct and return a
42 * pointer to that new struct.
44 * Return NULL if the memory could not be allocated.
46 struct cec_notifier *cec_notifier_get(struct device *dev);
49 * cec_notifier_put - decrease refcount and delete when the refcount reaches 0.
52 void cec_notifier_put(struct cec_notifier *n);
55 * cec_notifier_set_phys_addr - set a new physical address.
56 * @n: the CEC notifier
57 * @pa: the CEC physical address
59 * Set a new CEC physical address.
61 void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa);
64 * cec_notifier_set_phys_addr_from_edid - set parse the PA from the EDID.
65 * @n: the CEC notifier
66 * @edid: the struct edid pointer
68 * Parses the EDID to obtain the new CEC physical address and set it.
70 void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n,
71 const struct edid *edid);
74 * cec_notifier_register - register a callback with the notifier
75 * @n: the CEC notifier
76 * @adap: the CEC adapter, passed as argument to the callback function
77 * @callback: the callback function
79 void cec_notifier_register(struct cec_notifier *n,
80 struct cec_adapter *adap,
81 void (*callback)(struct cec_adapter *adap, u16 pa));
84 * cec_notifier_unregister - unregister the callback from the notifier.
85 * @n: the CEC notifier
87 void cec_notifier_unregister(struct cec_notifier *n);
90 static inline struct cec_notifier *cec_notifier_get(struct device *dev)
92 /* A non-NULL pointer is expected on success */
93 return (struct cec_notifier *)0xdeadfeed;
96 static inline void cec_notifier_put(struct cec_notifier *n)
100 static inline void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa)
104 static inline void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n,
105 const struct edid *edid)
109 static inline void cec_notifier_register(struct cec_notifier *n,
110 struct cec_adapter *adap,
111 void (*callback)(struct cec_adapter *adap, u16 pa))
115 static inline void cec_notifier_unregister(struct cec_notifier *n)