1 /* SPDX-License-Identifier: GPL-2.0-only */ << 2 /* 1 /* 3 * cec-notifier.h - notify CEC drivers of phys 2 * cec-notifier.h - notify CEC drivers of physical address changes 4 * 3 * 5 * Copyright 2016 Russell King. !! 4 * Copyright 2016 Russell King <rmk+kernel@arm.linux.org.uk> 6 * Copyright 2016-2017 Cisco Systems, Inc. and 5 * Copyright 2016-2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved. >> 6 * >> 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. >> 10 * >> 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 >> 18 * SOFTWARE. 7 */ 19 */ 8 20 9 #ifndef LINUX_CEC_NOTIFIER_H 21 #ifndef LINUX_CEC_NOTIFIER_H 10 #define LINUX_CEC_NOTIFIER_H 22 #define LINUX_CEC_NOTIFIER_H 11 23 12 #include <linux/err.h> !! 24 #include <linux/types.h> 13 #include <media/cec.h> 25 #include <media/cec.h> 14 26 15 struct device; 27 struct device; 16 struct edid; 28 struct edid; 17 struct cec_adapter; 29 struct cec_adapter; 18 struct cec_notifier; 30 struct cec_notifier; 19 31 20 #if IS_REACHABLE(CONFIG_CEC_CORE) && IS_ENABLE 32 #if IS_REACHABLE(CONFIG_CEC_CORE) && IS_ENABLED(CONFIG_CEC_NOTIFIER) 21 33 22 /** 34 /** 23 * cec_notifier_conn_register - find or create !! 35 * cec_notifier_get - find or create a new cec_notifier for the given device. 24 * HDMI device and connector tuple. !! 36 * @dev: device that sends the events. 25 * @hdmi_dev: HDMI device that sends the event << 26 * @port_name: the connector name from which t << 27 * if there is always only one HDMI connector << 28 * @conn_info: the connector info from which t << 29 * << 30 * If a notifier for device @dev and connector << 31 * increase the refcount and return that notif << 32 * << 33 * If it doesn't exist, then allocate a new no << 34 * pointer to that new struct. << 35 * << 36 * Return NULL if the memory could not be allo << 37 */ << 38 struct cec_notifier * << 39 cec_notifier_conn_register(struct device *hdmi << 40 const struct cec_co << 41 << 42 /** << 43 * cec_notifier_conn_unregister - decrease ref << 44 * refcount reaches 0. << 45 * @n: notifier. If NULL, then this function d << 46 */ << 47 void cec_notifier_conn_unregister(struct cec_n << 48 << 49 /** << 50 * cec_notifier_cec_adap_register - find or cr << 51 * given device. << 52 * @hdmi_dev: HDMI device that sends the event << 53 * @port_name: the connector name from which t << 54 * if there is always only one HDMI connector << 55 * @adap: the cec adapter that registered this << 56 * 37 * 57 * If a notifier for device @dev and connector !! 38 * If a notifier for device @dev already exists, then increase the refcount 58 * increase the refcount and return that notif !! 39 * and return that notifier. 59 * 40 * 60 * If it doesn't exist, then allocate a new no 41 * If it doesn't exist, then allocate a new notifier struct and return a 61 * pointer to that new struct. 42 * pointer to that new struct. 62 * 43 * 63 * Return NULL if the memory could not be allo 44 * Return NULL if the memory could not be allocated. 64 */ 45 */ 65 struct cec_notifier * !! 46 struct cec_notifier *cec_notifier_get(struct device *dev); 66 cec_notifier_cec_adap_register(struct device * << 67 struct cec_adap << 68 47 69 /** 48 /** 70 * cec_notifier_cec_adap_unregister - decrease !! 49 * cec_notifier_put - decrease refcount and delete when the refcount reaches 0. 71 * refcount reaches 0. !! 50 * @n: notifier 72 * @n: notifier. If NULL, then this function d << 73 * @adap: the cec adapter that registered this << 74 */ 51 */ 75 void cec_notifier_cec_adap_unregister(struct c !! 52 void cec_notifier_put(struct cec_notifier *n); 76 struct c << 77 53 78 /** 54 /** 79 * cec_notifier_set_phys_addr - set a new phys 55 * cec_notifier_set_phys_addr - set a new physical address. 80 * @n: the CEC notifier 56 * @n: the CEC notifier 81 * @pa: the CEC physical address 57 * @pa: the CEC physical address 82 * 58 * 83 * Set a new CEC physical address. 59 * Set a new CEC physical address. 84 * Does nothing if @n == NULL. 60 * Does nothing if @n == NULL. 85 */ 61 */ 86 void cec_notifier_set_phys_addr(struct cec_not 62 void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa); 87 63 88 /** 64 /** 89 * cec_notifier_set_phys_addr_from_edid - set 65 * cec_notifier_set_phys_addr_from_edid - set parse the PA from the EDID. 90 * @n: the CEC notifier 66 * @n: the CEC notifier 91 * @edid: the struct edid pointer 67 * @edid: the struct edid pointer 92 * 68 * 93 * Parses the EDID to obtain the new CEC physi 69 * Parses the EDID to obtain the new CEC physical address and set it. 94 * Does nothing if @n == NULL. 70 * Does nothing if @n == NULL. 95 */ 71 */ 96 void cec_notifier_set_phys_addr_from_edid(stru 72 void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, 97 cons 73 const struct edid *edid); 98 74 99 /** 75 /** 100 * cec_notifier_parse_hdmi_phandle - find the !! 76 * cec_notifier_register - register a callback with the notifier 101 * @dev: the device with the "hdmi-phandle" de !! 77 * @n: the CEC notifier 102 * !! 78 * @adap: the CEC adapter, passed as argument to the callback function 103 * Returns the device pointer referenced by th !! 79 * @callback: the callback function 104 * Note that the refcount of the returned devi << 105 * This device pointer is only used as a key v << 106 * list, but it is never accessed by the CEC d << 107 */ 80 */ 108 struct device *cec_notifier_parse_hdmi_phandle !! 81 void cec_notifier_register(struct cec_notifier *n, >> 82 struct cec_adapter *adap, >> 83 void (*callback)(struct cec_adapter *adap, u16 pa)); 109 84 110 #else !! 85 /** >> 86 * cec_notifier_unregister - unregister the callback from the notifier. >> 87 * @n: the CEC notifier >> 88 */ >> 89 void cec_notifier_unregister(struct cec_notifier *n); >> 90 >> 91 /** >> 92 * cec_register_cec_notifier - register the notifier with the cec adapter. >> 93 * @adap: the CEC adapter >> 94 * @notifier: the CEC notifier >> 95 */ >> 96 void cec_register_cec_notifier(struct cec_adapter *adap, >> 97 struct cec_notifier *notifier); 111 98 112 static inline struct cec_notifier * !! 99 #else 113 cec_notifier_conn_register(struct device *hdmi !! 100 static inline struct cec_notifier *cec_notifier_get(struct device *dev) 114 const struct cec_co << 115 { 101 { 116 /* A non-NULL pointer is expected on s 102 /* A non-NULL pointer is expected on success */ 117 return (struct cec_notifier *)0xdeadfe 103 return (struct cec_notifier *)0xdeadfeed; 118 } 104 } 119 105 120 static inline void cec_notifier_conn_unregiste !! 106 static inline void cec_notifier_put(struct cec_notifier *n) 121 { 107 { 122 } 108 } 123 109 124 static inline struct cec_notifier * !! 110 static inline void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa) 125 cec_notifier_cec_adap_register(struct device * << 126 struct cec_adap << 127 { 111 { 128 /* A non-NULL pointer is expected on s << 129 return (struct cec_notifier *)0xdeadfe << 130 } 112 } 131 113 132 static inline void cec_notifier_cec_adap_unreg !! 114 static inline void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, 133 !! 115 const struct edid *edid) 134 { 116 { 135 } 117 } 136 118 137 static inline void cec_notifier_set_phys_addr( !! 119 static inline void cec_notifier_register(struct cec_notifier *n, >> 120 struct cec_adapter *adap, >> 121 void (*callback)(struct cec_adapter *adap, u16 pa)) 138 { 122 { 139 } 123 } 140 124 141 static inline void cec_notifier_set_phys_addr_ !! 125 static inline void cec_notifier_unregister(struct cec_notifier *n) 142 << 143 { 126 { 144 } 127 } 145 128 146 static inline struct device *cec_notifier_pars !! 129 static inline void cec_register_cec_notifier(struct cec_adapter *adap, >> 130 struct cec_notifier *notifier) 147 { 131 { 148 return ERR_PTR(-ENODEV); << 149 } 132 } 150 << 151 #endif 133 #endif 152 134 153 /** 135 /** 154 * cec_notifier_phys_addr_invalidate() - set t 136 * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID 155 * 137 * 156 * @n: the CEC notifier 138 * @n: the CEC notifier 157 * 139 * 158 * This is a simple helper function to invalid 140 * This is a simple helper function to invalidate the physical 159 * address. Does nothing if @n == NULL. 141 * address. Does nothing if @n == NULL. 160 */ 142 */ 161 static inline void cec_notifier_phys_addr_inva 143 static inline void cec_notifier_phys_addr_invalidate(struct cec_notifier *n) 162 { 144 { 163 cec_notifier_set_phys_addr(n, CEC_PHYS 145 cec_notifier_set_phys_addr(n, CEC_PHYS_ADDR_INVALID); 164 } 146 } 165 147 166 #endif 148 #endif 167 149
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.