]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/media/cec-notifier.h
net/dst: add new function skb_dst_update_pmtu_no_confirm
[mirror_ubuntu-bionic-kernel.git] / include / media / cec-notifier.h
CommitLineData
6917a7b7
HV
1/*
2 * cec-notifier.h - notify CEC drivers of physical address changes
3 *
4 * Copyright 2016 Russell King <rmk+kernel@arm.linux.org.uk>
5 * Copyright 2016-2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
6 *
7 * This program is free software; you may redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
12 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
15 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
16 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
17 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 * SOFTWARE.
19 */
20
21#ifndef LINUX_CEC_NOTIFIER_H
22#define LINUX_CEC_NOTIFIER_H
23
24#include <linux/types.h>
ee7e9871 25#include <media/cec.h>
6917a7b7
HV
26
27struct device;
28struct edid;
29struct cec_adapter;
30struct cec_notifier;
31
e94c3281 32#if IS_REACHABLE(CONFIG_CEC_CORE) && IS_ENABLED(CONFIG_CEC_NOTIFIER)
6917a7b7
HV
33
34/**
35 * cec_notifier_get - find or create a new cec_notifier for the given device.
36 * @dev: device that sends the events.
37 *
38 * If a notifier for device @dev already exists, then increase the refcount
39 * and return that notifier.
40 *
41 * If it doesn't exist, then allocate a new notifier struct and return a
42 * pointer to that new struct.
43 *
44 * Return NULL if the memory could not be allocated.
45 */
46struct cec_notifier *cec_notifier_get(struct device *dev);
47
48/**
49 * cec_notifier_put - decrease refcount and delete when the refcount reaches 0.
50 * @n: notifier
51 */
52void cec_notifier_put(struct cec_notifier *n);
53
54/**
55 * cec_notifier_set_phys_addr - set a new physical address.
56 * @n: the CEC notifier
57 * @pa: the CEC physical address
58 *
59 * Set a new CEC physical address.
fc1ff45a 60 * Does nothing if @n == NULL.
6917a7b7
HV
61 */
62void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa);
63
64/**
65 * cec_notifier_set_phys_addr_from_edid - set parse the PA from the EDID.
66 * @n: the CEC notifier
67 * @edid: the struct edid pointer
68 *
69 * Parses the EDID to obtain the new CEC physical address and set it.
fc1ff45a 70 * Does nothing if @n == NULL.
6917a7b7
HV
71 */
72void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n,
73 const struct edid *edid);
74
75/**
76 * cec_notifier_register - register a callback with the notifier
77 * @n: the CEC notifier
78 * @adap: the CEC adapter, passed as argument to the callback function
79 * @callback: the callback function
80 */
81void cec_notifier_register(struct cec_notifier *n,
82 struct cec_adapter *adap,
83 void (*callback)(struct cec_adapter *adap, u16 pa));
84
85/**
86 * cec_notifier_unregister - unregister the callback from the notifier.
87 * @n: the CEC notifier
88 */
89void cec_notifier_unregister(struct cec_notifier *n);
90
51504185
HV
91/**
92 * cec_register_cec_notifier - register the notifier with the cec adapter.
93 * @adap: the CEC adapter
94 * @notifier: the CEC notifier
95 */
96void cec_register_cec_notifier(struct cec_adapter *adap,
97 struct cec_notifier *notifier);
98
6917a7b7
HV
99#else
100static inline struct cec_notifier *cec_notifier_get(struct device *dev)
101{
102 /* A non-NULL pointer is expected on success */
103 return (struct cec_notifier *)0xdeadfeed;
104}
105
106static inline void cec_notifier_put(struct cec_notifier *n)
107{
108}
109
110static inline void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa)
111{
112}
113
114static inline void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n,
115 const struct edid *edid)
116{
117}
118
79eddc99
AB
119static inline void cec_notifier_register(struct cec_notifier *n,
120 struct cec_adapter *adap,
121 void (*callback)(struct cec_adapter *adap, u16 pa))
122{
123}
124
125static inline void cec_notifier_unregister(struct cec_notifier *n)
126{
127}
128
51504185
HV
129static inline void cec_register_cec_notifier(struct cec_adapter *adap,
130 struct cec_notifier *notifier)
131{
132}
6917a7b7
HV
133#endif
134
fc1ff45a
HV
135/**
136 * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID
137 *
138 * @n: the CEC notifier
139 *
140 * This is a simple helper function to invalidate the physical
141 * address. Does nothing if @n == NULL.
142 */
143static inline void cec_notifier_phys_addr_invalidate(struct cec_notifier *n)
144{
145 cec_notifier_set_phys_addr(n, CEC_PHYS_ADDR_INVALID);
146}
147
6917a7b7 148#endif