Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.6 189 lines 5.9 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * cec-notifier.h - notify CEC drivers of physical address changes 4 * 5 * Copyright 2016 Russell King <rmk+kernel@arm.linux.org.uk> 6 * Copyright 2016-2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved. 7 */ 8 9#ifndef LINUX_CEC_NOTIFIER_H 10#define LINUX_CEC_NOTIFIER_H 11 12#include <linux/err.h> 13#include <media/cec.h> 14 15struct device; 16struct edid; 17struct cec_adapter; 18struct cec_notifier; 19 20#if IS_REACHABLE(CONFIG_CEC_CORE) && IS_ENABLED(CONFIG_CEC_NOTIFIER) 21 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 */ 36struct cec_notifier *cec_notifier_get_conn(struct device *dev, 37 const char *conn); 38 39/** 40 * cec_notifier_conn_register - find or create a new cec_notifier for the given 41 * HDMI device and connector tuple. 42 * @hdmi_dev: HDMI device that sends the events. 43 * @conn_name: the connector name from which the event occurs. May be NULL 44 * if there is always only one HDMI connector created by the HDMI device. 45 * @conn_info: the connector info from which the event occurs (may be NULL) 46 * 47 * If a notifier for device @dev and connector @conn_name already exists, then 48 * increase the refcount and return that notifier. 49 * 50 * If it doesn't exist, then allocate a new notifier struct and return a 51 * pointer to that new struct. 52 * 53 * Return NULL if the memory could not be allocated. 54 */ 55struct cec_notifier * 56cec_notifier_conn_register(struct device *hdmi_dev, const char *conn_name, 57 const struct cec_connector_info *conn_info); 58 59/** 60 * cec_notifier_conn_unregister - decrease refcount and delete when the 61 * refcount reaches 0. 62 * @n: notifier. If NULL, then this function does nothing. 63 */ 64void cec_notifier_conn_unregister(struct cec_notifier *n); 65 66/** 67 * cec_notifier_cec_adap_register - find or create a new cec_notifier for the 68 * given device. 69 * @hdmi_dev: HDMI device that sends the events. 70 * @conn_name: the connector name from which the event occurs. May be NULL 71 * if there is always only one HDMI connector created by the HDMI device. 72 * @adap: the cec adapter that registered this notifier. 73 * 74 * If a notifier for device @dev and connector @conn_name already exists, then 75 * increase the refcount and return that notifier. 76 * 77 * If it doesn't exist, then allocate a new notifier struct and return a 78 * pointer to that new struct. 79 * 80 * Return NULL if the memory could not be allocated. 81 */ 82struct cec_notifier * 83cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *conn_name, 84 struct cec_adapter *adap); 85 86/** 87 * cec_notifier_cec_adap_unregister - decrease refcount and delete when the 88 * refcount reaches 0. 89 * @n: notifier. If NULL, then this function does nothing. 90 * @adap: the cec adapter that registered this notifier. 91 */ 92void cec_notifier_cec_adap_unregister(struct cec_notifier *n, 93 struct cec_adapter *adap); 94 95/** 96 * cec_notifier_set_phys_addr - set a new physical address. 97 * @n: the CEC notifier 98 * @pa: the CEC physical address 99 * 100 * Set a new CEC physical address. 101 * Does nothing if @n == NULL. 102 */ 103void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa); 104 105/** 106 * cec_notifier_set_phys_addr_from_edid - set parse the PA from the EDID. 107 * @n: the CEC notifier 108 * @edid: the struct edid pointer 109 * 110 * Parses the EDID to obtain the new CEC physical address and set it. 111 * Does nothing if @n == NULL. 112 */ 113void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, 114 const struct edid *edid); 115 116/** 117 * cec_notifier_parse_hdmi_phandle - find the hdmi device from "hdmi-phandle" 118 * @dev: the device with the "hdmi-phandle" device tree property 119 * 120 * Returns the device pointer referenced by the "hdmi-phandle" property. 121 * Note that the refcount of the returned device is not incremented. 122 * This device pointer is only used as a key value in the notifier 123 * list, but it is never accessed by the CEC driver. 124 */ 125struct device *cec_notifier_parse_hdmi_phandle(struct device *dev); 126 127#else 128static inline struct cec_notifier *cec_notifier_get_conn(struct device *dev, 129 const char *conn) 130{ 131 /* A non-NULL pointer is expected on success */ 132 return (struct cec_notifier *)0xdeadfeed; 133} 134 135static inline struct cec_notifier * 136cec_notifier_conn_register(struct device *hdmi_dev, const char *conn_name, 137 const struct cec_connector_info *conn_info) 138{ 139 /* A non-NULL pointer is expected on success */ 140 return (struct cec_notifier *)0xdeadfeed; 141} 142 143static inline void cec_notifier_conn_unregister(struct cec_notifier *n) 144{ 145} 146 147static inline struct cec_notifier * 148cec_notifier_cec_adap_register(struct device *hdmi_dev, const char *conn_name, 149 struct cec_adapter *adap) 150{ 151 /* A non-NULL pointer is expected on success */ 152 return (struct cec_notifier *)0xdeadfeed; 153} 154 155static inline void cec_notifier_cec_adap_unregister(struct cec_notifier *n, 156 struct cec_adapter *adap) 157{ 158} 159 160static inline void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa) 161{ 162} 163 164static inline void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, 165 const struct edid *edid) 166{ 167} 168 169static inline struct device *cec_notifier_parse_hdmi_phandle(struct device *dev) 170{ 171 return ERR_PTR(-ENODEV); 172} 173 174#endif 175 176/** 177 * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID 178 * 179 * @n: the CEC notifier 180 * 181 * This is a simple helper function to invalidate the physical 182 * address. Does nothing if @n == NULL. 183 */ 184static inline void cec_notifier_phys_addr_invalidate(struct cec_notifier *n) 185{ 186 cec_notifier_set_phys_addr(n, CEC_PHYS_ADDR_INVALID); 187} 188 189#endif