Hans Verkuil | ea5c8ef | 2017-07-11 03:30:42 -0300 | [diff] [blame] | 1 | /* |
| 2 | * cec-pin.h - low-level CEC pin control |
| 3 | * |
| 4 | * Copyright 2017 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 LINUX_CEC_PIN_H |
| 21 | #define LINUX_CEC_PIN_H |
| 22 | |
| 23 | #include <linux/types.h> |
Hans Verkuil | ea5c8ef | 2017-07-11 03:30:42 -0300 | [diff] [blame] | 24 | #include <media/cec.h> |
| 25 | |
Hans Verkuil | ea5c8ef | 2017-07-11 03:30:42 -0300 | [diff] [blame] | 26 | /** |
| 27 | * struct cec_pin_ops - low-level CEC pin operations |
| 28 | * @read: read the CEC pin. Return true if high, false if low. |
| 29 | * @low: drive the CEC pin low. |
| 30 | * @high: stop driving the CEC pin. The pull-up will drive the pin |
| 31 | * high, unless someone else is driving the pin low. |
| 32 | * @enable_irq: optional, enable the interrupt to detect pin voltage changes. |
| 33 | * @disable_irq: optional, disable the interrupt. |
| 34 | * @free: optional. Free any allocated resources. Called when the |
| 35 | * adapter is deleted. |
| 36 | * @status: optional, log status information. |
Hans Verkuil | 333ef6b | 2017-08-15 10:07:25 -0400 | [diff] [blame] | 37 | * @read_hpd: read the HPD pin. Return true if high, false if low or |
| 38 | * an error if negative. If NULL or -ENOTTY is returned, |
| 39 | * then this is not supported. |
Hans Verkuil | ea5c8ef | 2017-07-11 03:30:42 -0300 | [diff] [blame] | 40 | * |
| 41 | * These operations are used by the cec pin framework to manipulate |
| 42 | * the CEC pin. |
| 43 | */ |
| 44 | struct cec_pin_ops { |
| 45 | bool (*read)(struct cec_adapter *adap); |
| 46 | void (*low)(struct cec_adapter *adap); |
| 47 | void (*high)(struct cec_adapter *adap); |
| 48 | bool (*enable_irq)(struct cec_adapter *adap); |
| 49 | void (*disable_irq)(struct cec_adapter *adap); |
| 50 | void (*free)(struct cec_adapter *adap); |
| 51 | void (*status)(struct cec_adapter *adap, struct seq_file *file); |
Hans Verkuil | 333ef6b | 2017-08-15 10:07:25 -0400 | [diff] [blame] | 52 | int (*read_hpd)(struct cec_adapter *adap); |
Hans Verkuil | ea5c8ef | 2017-07-11 03:30:42 -0300 | [diff] [blame] | 53 | }; |
| 54 | |
Hans Verkuil | ea5c8ef | 2017-07-11 03:30:42 -0300 | [diff] [blame] | 55 | /** |
| 56 | * cec_pin_changed() - update pin state from interrupt |
| 57 | * |
| 58 | * @adap: pointer to the cec adapter |
| 59 | * @value: when true the pin is high, otherwise it is low |
| 60 | * |
| 61 | * If changes of the CEC voltage are detected via an interrupt, then |
| 62 | * cec_pin_changed is called from the interrupt with the new value. |
| 63 | */ |
| 64 | void cec_pin_changed(struct cec_adapter *adap, bool value); |
| 65 | |
| 66 | /** |
| 67 | * cec_pin_allocate_adapter() - allocate a pin-based cec adapter |
| 68 | * |
| 69 | * @pin_ops: low-level pin operations |
| 70 | * @priv: will be stored in adap->priv and can be used by the adapter ops. |
| 71 | * Use cec_get_drvdata(adap) to get the priv pointer. |
| 72 | * @name: the name of the CEC adapter. Note: this name will be copied. |
| 73 | * @caps: capabilities of the CEC adapter. This will be ORed with |
| 74 | * CEC_CAP_MONITOR_ALL and CEC_CAP_MONITOR_PIN. |
| 75 | * |
| 76 | * Allocate a cec adapter using the cec pin framework. |
| 77 | * |
| 78 | * Return: a pointer to the cec adapter or an error pointer |
| 79 | */ |
| 80 | struct cec_adapter *cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops, |
| 81 | void *priv, const char *name, u32 caps); |
| 82 | |
| 83 | #endif |