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