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_conn - find or create a new cec_notifier for the given 24 * HDMI device and connector tuple. !! 24 * device and connector tuple. 25 * @hdmi_dev: HDMI device that sends the event !! 25 * @dev: device that sends the events. 26 * @port_name: the connector name from which t !! 26 * @conn: the connector name from which the event occurs 27 * if there is always only one HDMI connector << 28 * @conn_info: the connector info from which t << 29 * 27 * 30 * If a notifier for device @dev and connector !! 28 * If a notifier for device @dev already exists, then increase the refcount 31 * increase the refcount and return that notif !! 29 * and return that notifier. 32 * 30 * 33 * If it doesn't exist, then allocate a new no 31 * If it doesn't exist, then allocate a new notifier struct and return a 34 * pointer to that new struct. 32 * pointer to that new struct. 35 * 33 * 36 * Return NULL if the memory could not be allo 34 * Return NULL if the memory could not be allocated. 37 */ 35 */ 38 struct cec_notifier * !! 36 struct cec_notifier *cec_notifier_get_conn(struct device *dev, 39 cec_notifier_conn_register(struct device *hdmi !! 37 const char *conn); 40 const struct cec_co << 41 38 42 /** 39 /** 43 * cec_notifier_conn_unregister - decrease ref !! 40 * cec_notifier_put - decrease refcount and delete when the refcount reaches 0. 44 * refcount reaches 0. !! 41 * @n: notifier 45 * @n: notifier. If NULL, then this function d << 46 */ 42 */ 47 void cec_notifier_conn_unregister(struct cec_n !! 43 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 44 78 /** 45 /** 79 * cec_notifier_set_phys_addr - set a new phys 46 * cec_notifier_set_phys_addr - set a new physical address. 80 * @n: the CEC notifier 47 * @n: the CEC notifier 81 * @pa: the CEC physical address 48 * @pa: the CEC physical address 82 * 49 * 83 * Set a new CEC physical address. 50 * Set a new CEC physical address. 84 * Does nothing if @n == NULL. 51 * Does nothing if @n == NULL. 85 */ 52 */ 86 void cec_notifier_set_phys_addr(struct cec_not 53 void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa); 87 54 88 /** 55 /** 89 * cec_notifier_set_phys_addr_from_edid - set 56 * cec_notifier_set_phys_addr_from_edid - set parse the PA from the EDID. 90 * @n: the CEC notifier 57 * @n: the CEC notifier 91 * @edid: the struct edid pointer 58 * @edid: the struct edid pointer 92 * 59 * 93 * Parses the EDID to obtain the new CEC physi 60 * Parses the EDID to obtain the new CEC physical address and set it. 94 * Does nothing if @n == NULL. 61 * Does nothing if @n == NULL. 95 */ 62 */ 96 void cec_notifier_set_phys_addr_from_edid(stru 63 void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, 97 cons 64 const struct edid *edid); 98 65 99 /** 66 /** 100 * cec_notifier_parse_hdmi_phandle - find the !! 67 * cec_notifier_register - register a callback with the notifier 101 * @dev: the device with the "hdmi-phandle" de !! 68 * @n: the CEC notifier 102 * !! 69 * @adap: the CEC adapter, passed as argument to the callback function 103 * Returns the device pointer referenced by th !! 70 * @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 */ 71 */ 108 struct device *cec_notifier_parse_hdmi_phandle !! 72 void cec_notifier_register(struct cec_notifier *n, >> 73 struct cec_adapter *adap, >> 74 void (*callback)(struct cec_adapter *adap, u16 pa)); 109 75 110 #else !! 76 /** >> 77 * cec_notifier_unregister - unregister the callback from the notifier. >> 78 * @n: the CEC notifier >> 79 */ >> 80 void cec_notifier_unregister(struct cec_notifier *n); >> 81 >> 82 /** >> 83 * cec_register_cec_notifier - register the notifier with the cec adapter. >> 84 * @adap: the CEC adapter >> 85 * @notifier: the CEC notifier >> 86 */ >> 87 void cec_register_cec_notifier(struct cec_adapter *adap, >> 88 struct cec_notifier *notifier); 111 89 112 static inline struct cec_notifier * !! 90 #else 113 cec_notifier_conn_register(struct device *hdmi !! 91 static inline struct cec_notifier *cec_notifier_get_conn(struct device *dev, 114 const struct cec_co !! 92 const char *conn) 115 { 93 { 116 /* A non-NULL pointer is expected on s 94 /* A non-NULL pointer is expected on success */ 117 return (struct cec_notifier *)0xdeadfe 95 return (struct cec_notifier *)0xdeadfeed; 118 } 96 } 119 97 120 static inline void cec_notifier_conn_unregiste !! 98 static inline void cec_notifier_put(struct cec_notifier *n) 121 { 99 { 122 } 100 } 123 101 124 static inline struct cec_notifier * !! 102 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 { 103 { 128 /* A non-NULL pointer is expected on s << 129 return (struct cec_notifier *)0xdeadfe << 130 } 104 } 131 105 132 static inline void cec_notifier_cec_adap_unreg !! 106 static inline void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, 133 !! 107 const struct edid *edid) 134 { 108 { 135 } 109 } 136 110 137 static inline void cec_notifier_set_phys_addr( !! 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)) 138 { 114 { 139 } 115 } 140 116 141 static inline void cec_notifier_set_phys_addr_ !! 117 static inline void cec_notifier_unregister(struct cec_notifier *n) 142 << 143 { 118 { 144 } 119 } 145 120 146 static inline struct device *cec_notifier_pars !! 121 static inline void cec_register_cec_notifier(struct cec_adapter *adap, >> 122 struct cec_notifier *notifier) 147 { 123 { 148 return ERR_PTR(-ENODEV); << 149 } 124 } 150 << 151 #endif 125 #endif >> 126 >> 127 /** >> 128 * cec_notifier_get - find or create a new cec_notifier for the given device. >> 129 * @dev: device that sends the events. >> 130 * >> 131 * If a notifier for device @dev already exists, then increase the refcount >> 132 * and return that notifier. >> 133 * >> 134 * If it doesn't exist, then allocate a new notifier struct and return a >> 135 * pointer to that new struct. >> 136 * >> 137 * Return NULL if the memory could not be allocated. >> 138 */ >> 139 static inline struct cec_notifier *cec_notifier_get(struct device *dev) >> 140 { >> 141 return cec_notifier_get_conn(dev, NULL); >> 142 } 152 143 153 /** 144 /** 154 * cec_notifier_phys_addr_invalidate() - set t 145 * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID 155 * 146 * 156 * @n: the CEC notifier 147 * @n: the CEC notifier 157 * 148 * 158 * This is a simple helper function to invalid 149 * This is a simple helper function to invalidate the physical 159 * address. Does nothing if @n == NULL. 150 * address. Does nothing if @n == NULL. 160 */ 151 */ 161 static inline void cec_notifier_phys_addr_inva 152 static inline void cec_notifier_phys_addr_invalidate(struct cec_notifier *n) 162 { 153 { 163 cec_notifier_set_phys_addr(n, CEC_PHYS 154 cec_notifier_set_phys_addr(n, CEC_PHYS_ADDR_INVALID); 164 } 155 } 165 156 166 #endif 157 #endif 167 158
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.