.. | .. |
---|
2 | 2 | /* |
---|
3 | 3 | * cec-notifier.h - notify CEC drivers of physical address changes |
---|
4 | 4 | * |
---|
5 | | - * Copyright 2016 Russell King <rmk+kernel@arm.linux.org.uk> |
---|
| 5 | + * Copyright 2016 Russell King. |
---|
6 | 6 | * Copyright 2016-2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved. |
---|
7 | 7 | */ |
---|
8 | 8 | |
---|
9 | 9 | #ifndef LINUX_CEC_NOTIFIER_H |
---|
10 | 10 | #define LINUX_CEC_NOTIFIER_H |
---|
11 | 11 | |
---|
12 | | -#include <linux/types.h> |
---|
| 12 | +#include <linux/err.h> |
---|
13 | 13 | #include <media/cec.h> |
---|
14 | 14 | |
---|
15 | 15 | struct device; |
---|
.. | .. |
---|
20 | 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 |
---|
| 23 | + * cec_notifier_conn_register - find or create a new cec_notifier for the given |
---|
| 24 | + * HDMI device and connector tuple. |
---|
| 25 | + * @hdmi_dev: HDMI device that sends the events. |
---|
| 26 | + * @port_name: the connector name from which the event occurs. May be NULL |
---|
| 27 | + * if there is always only one HDMI connector created by the HDMI device. |
---|
| 28 | + * @conn_info: the connector info from which the event occurs (may be NULL) |
---|
27 | 29 | * |
---|
28 | | - * If a notifier for device @dev already exists, then increase the refcount |
---|
29 | | - * and return that notifier. |
---|
| 30 | + * If a notifier for device @dev and connector @port_name already exists, then |
---|
| 31 | + * increase the refcount and return that notifier. |
---|
30 | 32 | * |
---|
31 | 33 | * If it doesn't exist, then allocate a new notifier struct and return a |
---|
32 | 34 | * pointer to that new struct. |
---|
33 | 35 | * |
---|
34 | 36 | * Return NULL if the memory could not be allocated. |
---|
35 | 37 | */ |
---|
36 | | -struct cec_notifier *cec_notifier_get_conn(struct device *dev, |
---|
37 | | - const char *conn); |
---|
| 38 | +struct cec_notifier * |
---|
| 39 | +cec_notifier_conn_register(struct device *hdmi_dev, const char *port_name, |
---|
| 40 | + const struct cec_connector_info *conn_info); |
---|
38 | 41 | |
---|
39 | 42 | /** |
---|
40 | | - * cec_notifier_put - decrease refcount and delete when the refcount reaches 0. |
---|
41 | | - * @n: notifier |
---|
| 43 | + * cec_notifier_conn_unregister - decrease refcount and delete when the |
---|
| 44 | + * refcount reaches 0. |
---|
| 45 | + * @n: notifier. If NULL, then this function does nothing. |
---|
42 | 46 | */ |
---|
43 | | -void cec_notifier_put(struct cec_notifier *n); |
---|
| 47 | +void cec_notifier_conn_unregister(struct cec_notifier *n); |
---|
| 48 | + |
---|
| 49 | +/** |
---|
| 50 | + * cec_notifier_cec_adap_register - find or create a new cec_notifier for the |
---|
| 51 | + * given device. |
---|
| 52 | + * @hdmi_dev: HDMI device that sends the events. |
---|
| 53 | + * @port_name: the connector name from which the event occurs. May be NULL |
---|
| 54 | + * if there is always only one HDMI connector created by the HDMI device. |
---|
| 55 | + * @adap: the cec adapter that registered this notifier. |
---|
| 56 | + * |
---|
| 57 | + * If a notifier for device @dev and connector @port_name already exists, then |
---|
| 58 | + * increase the refcount and return that notifier. |
---|
| 59 | + * |
---|
| 60 | + * If it doesn't exist, then allocate a new notifier struct and return a |
---|
| 61 | + * pointer to that new struct. |
---|
| 62 | + * |
---|
| 63 | + * Return NULL if the memory could not be allocated. |
---|
| 64 | + */ |
---|
| 65 | +struct cec_notifier * |
---|
| 66 | +cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *port_name, |
---|
| 67 | + struct cec_adapter *adap); |
---|
| 68 | + |
---|
| 69 | +/** |
---|
| 70 | + * cec_notifier_cec_adap_unregister - decrease refcount and delete when the |
---|
| 71 | + * refcount reaches 0. |
---|
| 72 | + * @n: notifier. If NULL, then this function does nothing. |
---|
| 73 | + * @adap: the cec adapter that registered this notifier. |
---|
| 74 | + */ |
---|
| 75 | +void cec_notifier_cec_adap_unregister(struct cec_notifier *n, |
---|
| 76 | + struct cec_adapter *adap); |
---|
44 | 77 | |
---|
45 | 78 | /** |
---|
46 | 79 | * cec_notifier_set_phys_addr - set a new physical address. |
---|
.. | .. |
---|
51 | 84 | * Does nothing if @n == NULL. |
---|
52 | 85 | */ |
---|
53 | 86 | void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa); |
---|
54 | | - |
---|
55 | | -void cec_notifier_repo_cec_hpd(struct cec_notifier *n, |
---|
56 | | - bool hpd_state, ktime_t ts); |
---|
57 | 87 | |
---|
58 | 88 | /** |
---|
59 | 89 | * cec_notifier_set_phys_addr_from_edid - set parse the PA from the EDID. |
---|
.. | .. |
---|
67 | 97 | const struct edid *edid); |
---|
68 | 98 | |
---|
69 | 99 | /** |
---|
70 | | - * cec_notifier_register - register a callback with the notifier |
---|
71 | | - * @n: the CEC notifier |
---|
72 | | - * @adap: the CEC adapter, passed as argument to the callback function |
---|
73 | | - * @callback: the callback function |
---|
| 100 | + * cec_notifier_parse_hdmi_phandle - find the hdmi device from "hdmi-phandle" |
---|
| 101 | + * @dev: the device with the "hdmi-phandle" device tree property |
---|
| 102 | + * |
---|
| 103 | + * Returns the device pointer referenced by the "hdmi-phandle" property. |
---|
| 104 | + * Note that the refcount of the returned device is not incremented. |
---|
| 105 | + * This device pointer is only used as a key value in the notifier |
---|
| 106 | + * list, but it is never accessed by the CEC driver. |
---|
74 | 107 | */ |
---|
75 | | -void cec_notifier_register(struct cec_notifier *n, |
---|
76 | | - struct cec_adapter *adap, |
---|
77 | | - void (*callback)(struct cec_adapter *adap, u16 pa)); |
---|
78 | | - |
---|
79 | | -/** |
---|
80 | | - * cec_notifier_unregister - unregister the callback from the notifier. |
---|
81 | | - * @n: the CEC notifier |
---|
82 | | - */ |
---|
83 | | -void cec_notifier_unregister(struct cec_notifier *n); |
---|
84 | | - |
---|
85 | | -/** |
---|
86 | | - * cec_register_cec_notifier - register the notifier with the cec adapter. |
---|
87 | | - * @adap: the CEC adapter |
---|
88 | | - * @notifier: the CEC notifier |
---|
89 | | - */ |
---|
90 | | -void cec_register_cec_notifier(struct cec_adapter *adap, |
---|
91 | | - struct cec_notifier *notifier); |
---|
| 108 | +struct device *cec_notifier_parse_hdmi_phandle(struct device *dev); |
---|
92 | 109 | |
---|
93 | 110 | #else |
---|
94 | | -static inline struct cec_notifier *cec_notifier_get_conn(struct device *dev, |
---|
95 | | - const char *conn) |
---|
| 111 | + |
---|
| 112 | +static inline struct cec_notifier * |
---|
| 113 | +cec_notifier_conn_register(struct device *hdmi_dev, const char *port_name, |
---|
| 114 | + const struct cec_connector_info *conn_info) |
---|
96 | 115 | { |
---|
97 | 116 | /* A non-NULL pointer is expected on success */ |
---|
98 | 117 | return (struct cec_notifier *)0xdeadfeed; |
---|
99 | 118 | } |
---|
100 | 119 | |
---|
101 | | -static inline void cec_notifier_put(struct cec_notifier *n) |
---|
| 120 | +static inline void cec_notifier_conn_unregister(struct cec_notifier *n) |
---|
| 121 | +{ |
---|
| 122 | +} |
---|
| 123 | + |
---|
| 124 | +static inline struct cec_notifier * |
---|
| 125 | +cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *port_name, |
---|
| 126 | + struct cec_adapter *adap) |
---|
| 127 | +{ |
---|
| 128 | + /* A non-NULL pointer is expected on success */ |
---|
| 129 | + return (struct cec_notifier *)0xdeadfeed; |
---|
| 130 | +} |
---|
| 131 | + |
---|
| 132 | +static inline void cec_notifier_cec_adap_unregister(struct cec_notifier *n, |
---|
| 133 | + struct cec_adapter *adap) |
---|
102 | 134 | { |
---|
103 | 135 | } |
---|
104 | 136 | |
---|
.. | .. |
---|
111 | 143 | { |
---|
112 | 144 | } |
---|
113 | 145 | |
---|
114 | | -static inline void cec_notifier_register(struct cec_notifier *n, |
---|
115 | | - struct cec_adapter *adap, |
---|
116 | | - void (*callback)(struct cec_adapter *adap, u16 pa)) |
---|
| 146 | +static inline struct device *cec_notifier_parse_hdmi_phandle(struct device *dev) |
---|
117 | 147 | { |
---|
| 148 | + return ERR_PTR(-ENODEV); |
---|
118 | 149 | } |
---|
119 | 150 | |
---|
120 | | -static inline void cec_notifier_unregister(struct cec_notifier *n) |
---|
121 | | -{ |
---|
122 | | -} |
---|
123 | | - |
---|
124 | | -static inline void cec_register_cec_notifier(struct cec_adapter *adap, |
---|
125 | | - struct cec_notifier *notifier) |
---|
126 | | -{ |
---|
127 | | -} |
---|
128 | 151 | #endif |
---|
129 | | - |
---|
130 | | -/** |
---|
131 | | - * cec_notifier_get - find or create a new cec_notifier for the given device. |
---|
132 | | - * @dev: device that sends the events. |
---|
133 | | - * |
---|
134 | | - * If a notifier for device @dev already exists, then increase the refcount |
---|
135 | | - * and return that notifier. |
---|
136 | | - * |
---|
137 | | - * If it doesn't exist, then allocate a new notifier struct and return a |
---|
138 | | - * pointer to that new struct. |
---|
139 | | - * |
---|
140 | | - * Return NULL if the memory could not be allocated. |
---|
141 | | - */ |
---|
142 | | -static inline struct cec_notifier *cec_notifier_get(struct device *dev) |
---|
143 | | -{ |
---|
144 | | - return cec_notifier_get_conn(dev, NULL); |
---|
145 | | -} |
---|
146 | 152 | |
---|
147 | 153 | /** |
---|
148 | 154 | * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID |
---|