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