diff options
-rw-r--r-- | MAINTAINERS | 1 | ||||
-rw-r--r-- | drivers/media/cec/cec-edid.c | 2 | ||||
-rw-r--r-- | drivers/media/cec/cec-notifier.c | 1 | ||||
-rw-r--r-- | drivers/media/platform/s5p-cec/s5p_cec.c | 1 | ||||
-rw-r--r-- | include/media/cec-edid.h | 133 | ||||
-rw-r--r-- | include/media/cec-notifier.h | 2 | ||||
-rw-r--r-- | include/media/cec.h | 102 |
7 files changed, 104 insertions, 138 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index cf0101544a08..84f185731b3c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -3077,7 +3077,6 @@ F: Documentation/media/uapi/cec | |||
3077 | F: drivers/media/cec/ | 3077 | F: drivers/media/cec/ |
3078 | F: drivers/media/rc/keymaps/rc-cec.c | 3078 | F: drivers/media/rc/keymaps/rc-cec.c |
3079 | F: include/media/cec.h | 3079 | F: include/media/cec.h |
3080 | F: include/media/cec-edid.h | ||
3081 | F: include/media/cec-notifier.h | 3080 | F: include/media/cec-notifier.h |
3082 | F: include/uapi/linux/cec.h | 3081 | F: include/uapi/linux/cec.h |
3083 | F: include/uapi/linux/cec-funcs.h | 3082 | F: include/uapi/linux/cec-funcs.h |
diff --git a/drivers/media/cec/cec-edid.c b/drivers/media/cec/cec-edid.c index c63dc81d2a29..38e3fec6152b 100644 --- a/drivers/media/cec/cec-edid.c +++ b/drivers/media/cec/cec-edid.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
23 | #include <media/cec-edid.h> | 23 | #include <media/cec.h> |
24 | 24 | ||
25 | /* | 25 | /* |
26 | * This EDID is expected to be a CEA-861 compliant, which means that there are | 26 | * This EDID is expected to be a CEA-861 compliant, which means that there are |
diff --git a/drivers/media/cec/cec-notifier.c b/drivers/media/cec/cec-notifier.c index 5f5209a73665..74dc1c32080e 100644 --- a/drivers/media/cec/cec-notifier.c +++ b/drivers/media/cec/cec-notifier.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/list.h> | 24 | #include <linux/list.h> |
25 | #include <linux/kref.h> | 25 | #include <linux/kref.h> |
26 | 26 | ||
27 | #include <media/cec.h> | ||
27 | #include <media/cec-notifier.h> | 28 | #include <media/cec-notifier.h> |
28 | #include <drm/drm_edid.h> | 29 | #include <drm/drm_edid.h> |
29 | 30 | ||
diff --git a/drivers/media/platform/s5p-cec/s5p_cec.c b/drivers/media/platform/s5p-cec/s5p_cec.c index 4688f0879f55..664937b61fa4 100644 --- a/drivers/media/platform/s5p-cec/s5p_cec.c +++ b/drivers/media/platform/s5p-cec/s5p_cec.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/timer.h> | 25 | #include <linux/timer.h> |
26 | #include <linux/workqueue.h> | 26 | #include <linux/workqueue.h> |
27 | #include <media/cec.h> | 27 | #include <media/cec.h> |
28 | #include <media/cec-edid.h> | ||
29 | #include <media/cec-notifier.h> | 28 | #include <media/cec-notifier.h> |
30 | 29 | ||
31 | #include "exynos_hdmi_cec.h" | 30 | #include "exynos_hdmi_cec.h" |
diff --git a/include/media/cec-edid.h b/include/media/cec-edid.h deleted file mode 100644 index 242781fd377f..000000000000 --- a/include/media/cec-edid.h +++ /dev/null | |||
@@ -1,133 +0,0 @@ | |||
1 | /* | ||
2 | * cec-edid - HDMI Consumer Electronics Control & EDID helpers | ||
3 | * | ||
4 | * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you may redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; version 2 of the License. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
11 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
12 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
13 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
14 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
16 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
17 | * SOFTWARE. | ||
18 | */ | ||
19 | |||
20 | #ifndef _MEDIA_CEC_EDID_H | ||
21 | #define _MEDIA_CEC_EDID_H | ||
22 | |||
23 | #include <linux/types.h> | ||
24 | |||
25 | #define CEC_PHYS_ADDR_INVALID 0xffff | ||
26 | #define cec_phys_addr_exp(pa) \ | ||
27 | ((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf | ||
28 | |||
29 | #if IS_ENABLED(CONFIG_CEC_CORE) | ||
30 | |||
31 | /** | ||
32 | * cec_get_edid_phys_addr() - find and return the physical address | ||
33 | * | ||
34 | * @edid: pointer to the EDID data | ||
35 | * @size: size in bytes of the EDID data | ||
36 | * @offset: If not %NULL then the location of the physical address | ||
37 | * bytes in the EDID will be returned here. This is set to 0 | ||
38 | * if there is no physical address found. | ||
39 | * | ||
40 | * Return: the physical address or CEC_PHYS_ADDR_INVALID if there is none. | ||
41 | */ | ||
42 | u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, | ||
43 | unsigned int *offset); | ||
44 | |||
45 | /** | ||
46 | * cec_set_edid_phys_addr() - find and set the physical address | ||
47 | * | ||
48 | * @edid: pointer to the EDID data | ||
49 | * @size: size in bytes of the EDID data | ||
50 | * @phys_addr: the new physical address | ||
51 | * | ||
52 | * This function finds the location of the physical address in the EDID | ||
53 | * and fills in the given physical address and updates the checksum | ||
54 | * at the end of the EDID block. It does nothing if the EDID doesn't | ||
55 | * contain a physical address. | ||
56 | */ | ||
57 | void cec_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr); | ||
58 | |||
59 | /** | ||
60 | * cec_phys_addr_for_input() - calculate the PA for an input | ||
61 | * | ||
62 | * @phys_addr: the physical address of the parent | ||
63 | * @input: the number of the input port, must be between 1 and 15 | ||
64 | * | ||
65 | * This function calculates a new physical address based on the input | ||
66 | * port number. For example: | ||
67 | * | ||
68 | * PA = 0.0.0.0 and input = 2 becomes 2.0.0.0 | ||
69 | * | ||
70 | * PA = 3.0.0.0 and input = 1 becomes 3.1.0.0 | ||
71 | * | ||
72 | * PA = 3.2.1.0 and input = 5 becomes 3.2.1.5 | ||
73 | * | ||
74 | * PA = 3.2.1.3 and input = 5 becomes f.f.f.f since it maxed out the depth. | ||
75 | * | ||
76 | * Return: the new physical address or CEC_PHYS_ADDR_INVALID. | ||
77 | */ | ||
78 | u16 cec_phys_addr_for_input(u16 phys_addr, u8 input); | ||
79 | |||
80 | /** | ||
81 | * cec_phys_addr_validate() - validate a physical address from an EDID | ||
82 | * | ||
83 | * @phys_addr: the physical address to validate | ||
84 | * @parent: if not %NULL, then this is filled with the parents PA. | ||
85 | * @port: if not %NULL, then this is filled with the input port. | ||
86 | * | ||
87 | * This validates a physical address as read from an EDID. If the | ||
88 | * PA is invalid (such as 1.0.1.0 since '0' is only allowed at the end), | ||
89 | * then it will return -EINVAL. | ||
90 | * | ||
91 | * The parent PA is passed into %parent and the input port is passed into | ||
92 | * %port. For example: | ||
93 | * | ||
94 | * PA = 0.0.0.0: has parent 0.0.0.0 and input port 0. | ||
95 | * | ||
96 | * PA = 1.0.0.0: has parent 0.0.0.0 and input port 1. | ||
97 | * | ||
98 | * PA = 3.2.0.0: has parent 3.0.0.0 and input port 2. | ||
99 | * | ||
100 | * PA = f.f.f.f: has parent f.f.f.f and input port 0. | ||
101 | * | ||
102 | * Return: 0 if the PA is valid, -EINVAL if not. | ||
103 | */ | ||
104 | int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port); | ||
105 | |||
106 | #else | ||
107 | |||
108 | static inline u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, | ||
109 | unsigned int *offset) | ||
110 | { | ||
111 | if (offset) | ||
112 | *offset = 0; | ||
113 | return CEC_PHYS_ADDR_INVALID; | ||
114 | } | ||
115 | |||
116 | static inline void cec_set_edid_phys_addr(u8 *edid, unsigned int size, | ||
117 | u16 phys_addr) | ||
118 | { | ||
119 | } | ||
120 | |||
121 | static inline u16 cec_phys_addr_for_input(u16 phys_addr, u8 input) | ||
122 | { | ||
123 | return CEC_PHYS_ADDR_INVALID; | ||
124 | } | ||
125 | |||
126 | static inline int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port) | ||
127 | { | ||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | #endif | ||
132 | |||
133 | #endif /* _MEDIA_CEC_EDID_H */ | ||
diff --git a/include/media/cec-notifier.h b/include/media/cec-notifier.h index 035712e0993d..eb50ce54b759 100644 --- a/include/media/cec-notifier.h +++ b/include/media/cec-notifier.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #define LINUX_CEC_NOTIFIER_H | 22 | #define LINUX_CEC_NOTIFIER_H |
23 | 23 | ||
24 | #include <linux/types.h> | 24 | #include <linux/types.h> |
25 | #include <media/cec-edid.h> | 25 | #include <media/cec.h> |
26 | 26 | ||
27 | struct device; | 27 | struct device; |
28 | struct edid; | 28 | struct edid; |
diff --git a/include/media/cec.h b/include/media/cec.h index bae8d0153de7..b8eb895731d5 100644 --- a/include/media/cec.h +++ b/include/media/cec.h | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/timer.h> | 29 | #include <linux/timer.h> |
30 | #include <linux/cec-funcs.h> | 30 | #include <linux/cec-funcs.h> |
31 | #include <media/rc-core.h> | 31 | #include <media/rc-core.h> |
32 | #include <media/cec-edid.h> | ||
33 | #include <media/cec-notifier.h> | 32 | #include <media/cec-notifier.h> |
34 | 33 | ||
35 | /** | 34 | /** |
@@ -204,6 +203,9 @@ static inline bool cec_is_sink(const struct cec_adapter *adap) | |||
204 | return adap->phys_addr == 0; | 203 | return adap->phys_addr == 0; |
205 | } | 204 | } |
206 | 205 | ||
206 | #define cec_phys_addr_exp(pa) \ | ||
207 | ((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf | ||
208 | |||
207 | #if IS_ENABLED(CONFIG_CEC_CORE) | 209 | #if IS_ENABLED(CONFIG_CEC_CORE) |
208 | struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, | 210 | struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, |
209 | void *priv, const char *name, u32 caps, u8 available_las); | 211 | void *priv, const char *name, u32 caps, u8 available_las); |
@@ -223,6 +225,81 @@ void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt, | |||
223 | u8 nack_cnt, u8 low_drive_cnt, u8 error_cnt); | 225 | u8 nack_cnt, u8 low_drive_cnt, u8 error_cnt); |
224 | void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg); | 226 | void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg); |
225 | 227 | ||
228 | /** | ||
229 | * cec_get_edid_phys_addr() - find and return the physical address | ||
230 | * | ||
231 | * @edid: pointer to the EDID data | ||
232 | * @size: size in bytes of the EDID data | ||
233 | * @offset: If not %NULL then the location of the physical address | ||
234 | * bytes in the EDID will be returned here. This is set to 0 | ||
235 | * if there is no physical address found. | ||
236 | * | ||
237 | * Return: the physical address or CEC_PHYS_ADDR_INVALID if there is none. | ||
238 | */ | ||
239 | u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, | ||
240 | unsigned int *offset); | ||
241 | |||
242 | /** | ||
243 | * cec_set_edid_phys_addr() - find and set the physical address | ||
244 | * | ||
245 | * @edid: pointer to the EDID data | ||
246 | * @size: size in bytes of the EDID data | ||
247 | * @phys_addr: the new physical address | ||
248 | * | ||
249 | * This function finds the location of the physical address in the EDID | ||
250 | * and fills in the given physical address and updates the checksum | ||
251 | * at the end of the EDID block. It does nothing if the EDID doesn't | ||
252 | * contain a physical address. | ||
253 | */ | ||
254 | void cec_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr); | ||
255 | |||
256 | /** | ||
257 | * cec_phys_addr_for_input() - calculate the PA for an input | ||
258 | * | ||
259 | * @phys_addr: the physical address of the parent | ||
260 | * @input: the number of the input port, must be between 1 and 15 | ||
261 | * | ||
262 | * This function calculates a new physical address based on the input | ||
263 | * port number. For example: | ||
264 | * | ||
265 | * PA = 0.0.0.0 and input = 2 becomes 2.0.0.0 | ||
266 | * | ||
267 | * PA = 3.0.0.0 and input = 1 becomes 3.1.0.0 | ||
268 | * | ||
269 | * PA = 3.2.1.0 and input = 5 becomes 3.2.1.5 | ||
270 | * | ||
271 | * PA = 3.2.1.3 and input = 5 becomes f.f.f.f since it maxed out the depth. | ||
272 | * | ||
273 | * Return: the new physical address or CEC_PHYS_ADDR_INVALID. | ||
274 | */ | ||
275 | u16 cec_phys_addr_for_input(u16 phys_addr, u8 input); | ||
276 | |||
277 | /** | ||
278 | * cec_phys_addr_validate() - validate a physical address from an EDID | ||
279 | * | ||
280 | * @phys_addr: the physical address to validate | ||
281 | * @parent: if not %NULL, then this is filled with the parents PA. | ||
282 | * @port: if not %NULL, then this is filled with the input port. | ||
283 | * | ||
284 | * This validates a physical address as read from an EDID. If the | ||
285 | * PA is invalid (such as 1.0.1.0 since '0' is only allowed at the end), | ||
286 | * then it will return -EINVAL. | ||
287 | * | ||
288 | * The parent PA is passed into %parent and the input port is passed into | ||
289 | * %port. For example: | ||
290 | * | ||
291 | * PA = 0.0.0.0: has parent 0.0.0.0 and input port 0. | ||
292 | * | ||
293 | * PA = 1.0.0.0: has parent 0.0.0.0 and input port 1. | ||
294 | * | ||
295 | * PA = 3.2.0.0: has parent 3.0.0.0 and input port 2. | ||
296 | * | ||
297 | * PA = f.f.f.f: has parent f.f.f.f and input port 0. | ||
298 | * | ||
299 | * Return: 0 if the PA is valid, -EINVAL if not. | ||
300 | */ | ||
301 | int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port); | ||
302 | |||
226 | #ifdef CONFIG_MEDIA_CEC_NOTIFIER | 303 | #ifdef CONFIG_MEDIA_CEC_NOTIFIER |
227 | void cec_register_cec_notifier(struct cec_adapter *adap, | 304 | void cec_register_cec_notifier(struct cec_adapter *adap, |
228 | struct cec_notifier *notifier); | 305 | struct cec_notifier *notifier); |
@@ -249,6 +326,29 @@ static inline void cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, | |||
249 | { | 326 | { |
250 | } | 327 | } |
251 | 328 | ||
329 | static inline u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, | ||
330 | unsigned int *offset) | ||
331 | { | ||
332 | if (offset) | ||
333 | *offset = 0; | ||
334 | return CEC_PHYS_ADDR_INVALID; | ||
335 | } | ||
336 | |||
337 | static inline void cec_set_edid_phys_addr(u8 *edid, unsigned int size, | ||
338 | u16 phys_addr) | ||
339 | { | ||
340 | } | ||
341 | |||
342 | static inline u16 cec_phys_addr_for_input(u16 phys_addr, u8 input) | ||
343 | { | ||
344 | return CEC_PHYS_ADDR_INVALID; | ||
345 | } | ||
346 | |||
347 | static inline int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port) | ||
348 | { | ||
349 | return 0; | ||
350 | } | ||
351 | |||
252 | #endif | 352 | #endif |
253 | 353 | ||
254 | #endif /* _MEDIA_CEC_H */ | 354 | #endif /* _MEDIA_CEC_H */ |