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/err.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_get_conn - find or create a new cec_notifier for the given >> 24 * device and connector tuple. >> 25 * @dev: device that sends the events. >> 26 * @conn: the connector name from which the event occurs >> 27 * >> 28 * If a notifier for device @dev already exists, then increase the refcount >> 29 * and return that notifier. >> 30 * >> 31 * If it doesn't exist, then allocate a new notifier struct and return a >> 32 * pointer to that new struct. >> 33 * >> 34 * Return NULL if the memory could not be allocated. >> 35 */ >> 36 struct cec_notifier *cec_notifier_get_conn(struct device *dev, >> 37 const char *conn); >> 38 >> 39 /** >> 40 * cec_notifier_put - decrease refcount and delete when the refcount reaches 0. >> 41 * @n: notifier >> 42 */ >> 43 void cec_notifier_put(struct cec_notifier *n); >> 44 >> 45 /** 23 * cec_notifier_conn_register - find or create 46 * cec_notifier_conn_register - find or create a new cec_notifier for the given 24 * HDMI device and connector tuple. 47 * HDMI device and connector tuple. 25 * @hdmi_dev: HDMI device that sends the event 48 * @hdmi_dev: HDMI device that sends the events. 26 * @port_name: the connector name from which t !! 49 * @conn_name: the connector name from which the event occurs. May be NULL 27 * if there is always only one HDMI connector 50 * if there is always only one HDMI connector created by the HDMI device. 28 * @conn_info: the connector info from which t 51 * @conn_info: the connector info from which the event occurs (may be NULL) 29 * 52 * 30 * If a notifier for device @dev and connector !! 53 * If a notifier for device @dev and connector @conn_name already exists, then 31 * increase the refcount and return that notif 54 * increase the refcount and return that notifier. 32 * 55 * 33 * If it doesn't exist, then allocate a new no 56 * If it doesn't exist, then allocate a new notifier struct and return a 34 * pointer to that new struct. 57 * pointer to that new struct. 35 * 58 * 36 * Return NULL if the memory could not be allo 59 * Return NULL if the memory could not be allocated. 37 */ 60 */ 38 struct cec_notifier * 61 struct cec_notifier * 39 cec_notifier_conn_register(struct device *hdmi !! 62 cec_notifier_conn_register(struct device *hdmi_dev, const char *conn_name, 40 const struct cec_co 63 const struct cec_connector_info *conn_info); 41 64 42 /** 65 /** 43 * cec_notifier_conn_unregister - decrease ref 66 * cec_notifier_conn_unregister - decrease refcount and delete when the 44 * refcount reaches 0. 67 * refcount reaches 0. 45 * @n: notifier. If NULL, then this function d 68 * @n: notifier. If NULL, then this function does nothing. 46 */ 69 */ 47 void cec_notifier_conn_unregister(struct cec_n 70 void cec_notifier_conn_unregister(struct cec_notifier *n); 48 71 49 /** 72 /** 50 * cec_notifier_cec_adap_register - find or cr 73 * cec_notifier_cec_adap_register - find or create a new cec_notifier for the 51 * given device. 74 * given device. 52 * @hdmi_dev: HDMI device that sends the event 75 * @hdmi_dev: HDMI device that sends the events. 53 * @port_name: the connector name from which t !! 76 * @conn_name: the connector name from which the event occurs. May be NULL 54 * if there is always only one HDMI connector 77 * if there is always only one HDMI connector created by the HDMI device. 55 * @adap: the cec adapter that registered this 78 * @adap: the cec adapter that registered this notifier. 56 * 79 * 57 * If a notifier for device @dev and connector !! 80 * If a notifier for device @dev and connector @conn_name already exists, then 58 * increase the refcount and return that notif 81 * increase the refcount and return that notifier. 59 * 82 * 60 * If it doesn't exist, then allocate a new no 83 * If it doesn't exist, then allocate a new notifier struct and return a 61 * pointer to that new struct. 84 * pointer to that new struct. 62 * 85 * 63 * Return NULL if the memory could not be allo 86 * Return NULL if the memory could not be allocated. 64 */ 87 */ 65 struct cec_notifier * 88 struct cec_notifier * 66 cec_notifier_cec_adap_register(struct device * !! 89 cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *conn_name, 67 struct cec_adap 90 struct cec_adapter *adap); 68 91 69 /** 92 /** 70 * cec_notifier_cec_adap_unregister - decrease 93 * cec_notifier_cec_adap_unregister - decrease refcount and delete when the 71 * refcount reaches 0. 94 * refcount reaches 0. 72 * @n: notifier. If NULL, then this function d 95 * @n: notifier. If NULL, then this function does nothing. 73 * @adap: the cec adapter that registered this 96 * @adap: the cec adapter that registered this notifier. 74 */ 97 */ 75 void cec_notifier_cec_adap_unregister(struct c 98 void cec_notifier_cec_adap_unregister(struct cec_notifier *n, 76 struct c 99 struct cec_adapter *adap); 77 100 78 /** 101 /** 79 * cec_notifier_set_phys_addr - set a new phys 102 * cec_notifier_set_phys_addr - set a new physical address. 80 * @n: the CEC notifier 103 * @n: the CEC notifier 81 * @pa: the CEC physical address 104 * @pa: the CEC physical address 82 * 105 * 83 * Set a new CEC physical address. 106 * Set a new CEC physical address. 84 * Does nothing if @n == NULL. 107 * Does nothing if @n == NULL. 85 */ 108 */ 86 void cec_notifier_set_phys_addr(struct cec_not 109 void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa); 87 110 88 /** 111 /** 89 * cec_notifier_set_phys_addr_from_edid - set 112 * cec_notifier_set_phys_addr_from_edid - set parse the PA from the EDID. 90 * @n: the CEC notifier 113 * @n: the CEC notifier 91 * @edid: the struct edid pointer 114 * @edid: the struct edid pointer 92 * 115 * 93 * Parses the EDID to obtain the new CEC physi 116 * Parses the EDID to obtain the new CEC physical address and set it. 94 * Does nothing if @n == NULL. 117 * Does nothing if @n == NULL. 95 */ 118 */ 96 void cec_notifier_set_phys_addr_from_edid(stru 119 void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, 97 cons 120 const struct edid *edid); 98 121 99 /** 122 /** 100 * cec_notifier_parse_hdmi_phandle - find the 123 * cec_notifier_parse_hdmi_phandle - find the hdmi device from "hdmi-phandle" 101 * @dev: the device with the "hdmi-phandle" de 124 * @dev: the device with the "hdmi-phandle" device tree property 102 * 125 * 103 * Returns the device pointer referenced by th 126 * Returns the device pointer referenced by the "hdmi-phandle" property. 104 * Note that the refcount of the returned devi 127 * Note that the refcount of the returned device is not incremented. 105 * This device pointer is only used as a key v 128 * This device pointer is only used as a key value in the notifier 106 * list, but it is never accessed by the CEC d 129 * list, but it is never accessed by the CEC driver. 107 */ 130 */ 108 struct device *cec_notifier_parse_hdmi_phandle 131 struct device *cec_notifier_parse_hdmi_phandle(struct device *dev); 109 132 110 #else 133 #else >> 134 static inline struct cec_notifier *cec_notifier_get_conn(struct device *dev, >> 135 const char *conn) >> 136 { >> 137 /* A non-NULL pointer is expected on success */ >> 138 return (struct cec_notifier *)0xdeadfeed; >> 139 } >> 140 >> 141 static inline void cec_notifier_put(struct cec_notifier *n) >> 142 { >> 143 } 111 144 112 static inline struct cec_notifier * 145 static inline struct cec_notifier * 113 cec_notifier_conn_register(struct device *hdmi !! 146 cec_notifier_conn_register(struct device *hdmi_dev, const char *conn_name, 114 const struct cec_co 147 const struct cec_connector_info *conn_info) 115 { 148 { 116 /* A non-NULL pointer is expected on s 149 /* A non-NULL pointer is expected on success */ 117 return (struct cec_notifier *)0xdeadfe 150 return (struct cec_notifier *)0xdeadfeed; 118 } 151 } 119 152 120 static inline void cec_notifier_conn_unregiste 153 static inline void cec_notifier_conn_unregister(struct cec_notifier *n) 121 { 154 { 122 } 155 } 123 156 124 static inline struct cec_notifier * 157 static inline struct cec_notifier * 125 cec_notifier_cec_adap_register(struct device * !! 158 cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *conn_name, 126 struct cec_adap 159 struct cec_adapter *adap) 127 { 160 { 128 /* A non-NULL pointer is expected on s 161 /* A non-NULL pointer is expected on success */ 129 return (struct cec_notifier *)0xdeadfe 162 return (struct cec_notifier *)0xdeadfeed; 130 } 163 } 131 164 132 static inline void cec_notifier_cec_adap_unreg 165 static inline void cec_notifier_cec_adap_unregister(struct cec_notifier *n, 133 166 struct cec_adapter *adap) 134 { 167 { 135 } 168 } 136 169 137 static inline void cec_notifier_set_phys_addr( 170 static inline void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa) 138 { 171 { 139 } 172 } 140 173 141 static inline void cec_notifier_set_phys_addr_ 174 static inline void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, 142 175 const struct edid *edid) 143 { 176 { 144 } 177 } 145 178 146 static inline struct device *cec_notifier_pars 179 static inline struct device *cec_notifier_parse_hdmi_phandle(struct device *dev) 147 { 180 { 148 return ERR_PTR(-ENODEV); 181 return ERR_PTR(-ENODEV); 149 } 182 } 150 183 151 #endif 184 #endif >> 185 >> 186 /** >> 187 * cec_notifier_get - find or create a new cec_notifier for the given device. >> 188 * @dev: device that sends the events. >> 189 * >> 190 * If a notifier for device @dev already exists, then increase the refcount >> 191 * and return that notifier. >> 192 * >> 193 * If it doesn't exist, then allocate a new notifier struct and return a >> 194 * pointer to that new struct. >> 195 * >> 196 * Return NULL if the memory could not be allocated. >> 197 */ >> 198 static inline struct cec_notifier *cec_notifier_get(struct device *dev) >> 199 { >> 200 return cec_notifier_get_conn(dev, NULL); >> 201 } 152 202 153 /** 203 /** 154 * cec_notifier_phys_addr_invalidate() - set t 204 * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID 155 * 205 * 156 * @n: the CEC notifier 206 * @n: the CEC notifier 157 * 207 * 158 * This is a simple helper function to invalid 208 * This is a simple helper function to invalidate the physical 159 * address. Does nothing if @n == NULL. 209 * address. Does nothing if @n == NULL. 160 */ 210 */ 161 static inline void cec_notifier_phys_addr_inva 211 static inline void cec_notifier_phys_addr_invalidate(struct cec_notifier *n) 162 { 212 { 163 cec_notifier_set_phys_addr(n, CEC_PHYS 213 cec_notifier_set_phys_addr(n, CEC_PHYS_ADDR_INVALID); 164 } 214 } 165 215 166 #endif 216 #endif 167 217
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.