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 /** 111 !! 86 * cec_notifier_unregister - unregister the callback from the notifier. 112 static inline struct cec_notifier * !! 87 * @n: the CEC notifier 113 cec_notifier_conn_register(struct device *hdmi !! 88 */ 114 const struct cec_co !! 89 void cec_notifier_unregister(struct cec_notifier *n); 115 { << 116 /* A non-NULL pointer is expected on s << 117 return (struct cec_notifier *)0xdeadfe << 118 } << 119 << 120 static inline void cec_notifier_conn_unregiste << 121 { << 122 } << 123 90 124 static inline struct cec_notifier * !! 91 #else 125 cec_notifier_cec_adap_register(struct device * !! 92 static inline struct cec_notifier *cec_notifier_get(struct device *dev) 126 struct cec_adap << 127 { 93 { 128 /* A non-NULL pointer is expected on s 94 /* A non-NULL pointer is expected on success */ 129 return (struct cec_notifier *)0xdeadfe 95 return (struct cec_notifier *)0xdeadfeed; 130 } 96 } 131 97 132 static inline void cec_notifier_cec_adap_unreg !! 98 static inline void cec_notifier_put(struct cec_notifier *n) 133 << 134 { 99 { 135 } 100 } 136 101 137 static inline void cec_notifier_set_phys_addr( 102 static inline void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa) 138 { 103 { 139 } 104 } 140 105 141 static inline void cec_notifier_set_phys_addr_ 106 static inline void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, 142 107 const struct edid *edid) 143 { 108 { 144 } 109 } 145 110 146 static inline struct device *cec_notifier_pars !! 111 static inline void cec_notifier_register(struct cec_notifier *n, >> 112 struct cec_adapter *adap, >> 113 void (*callback)(struct cec_adapter *adap, u16 pa)) >> 114 { >> 115 } >> 116 >> 117 static inline void cec_notifier_unregister(struct cec_notifier *n) 147 { 118 { 148 return ERR_PTR(-ENODEV); << 149 } 119 } 150 120 151 #endif 121 #endif 152 122 153 /** 123 /** 154 * cec_notifier_phys_addr_invalidate() - set t 124 * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID 155 * 125 * 156 * @n: the CEC notifier 126 * @n: the CEC notifier 157 * 127 * 158 * This is a simple helper function to invalid 128 * This is a simple helper function to invalidate the physical 159 * address. Does nothing if @n == NULL. 129 * address. Does nothing if @n == NULL. 160 */ 130 */ 161 static inline void cec_notifier_phys_addr_inva 131 static inline void cec_notifier_phys_addr_invalidate(struct cec_notifier *n) 162 { 132 { 163 cec_notifier_set_phys_addr(n, CEC_PHYS 133 cec_notifier_set_phys_addr(n, CEC_PHYS_ADDR_INVALID); 164 } 134 } 165 135 166 #endif 136 #endif 167 137
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.