/* SPDX-License-Identifier: GPL-2.0-only */1/*2* cec-pin.h - low-level CEC pin control3*4* Copyright 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.5*/67#ifndef LINUX_CEC_PIN_H8#define LINUX_CEC_PIN_H910#include <linux/types.h>11#include <media/cec.h>1213/**14* struct cec_pin_ops - low-level CEC pin operations15* @read: read the CEC pin. Returns > 0 if high, 0 if low, or an error16* if negative.17* @low: drive the CEC pin low.18* @high: stop driving the CEC pin. The pull-up will drive the pin19* high, unless someone else is driving the pin low.20* @enable_irq: optional, enable the interrupt to detect pin voltage changes.21* @disable_irq: optional, disable the interrupt.22* @free: optional. Free any allocated resources. Called when the23* adapter is deleted.24* @status: optional, log status information.25* @read_hpd: optional. Read the HPD pin. Returns > 0 if high, 0 if low or26* an error if negative.27* @read_5v: optional. Read the 5V pin. Returns > 0 if high, 0 if low or28* an error if negative.29* @received: optional. High-level CEC message callback. Allows the driver30* to process CEC messages.31*32* These operations (except for the @received op) are used by the33* cec pin framework to manipulate the CEC pin.34*/35struct cec_pin_ops {36int (*read)(struct cec_adapter *adap);37void (*low)(struct cec_adapter *adap);38void (*high)(struct cec_adapter *adap);39bool (*enable_irq)(struct cec_adapter *adap);40void (*disable_irq)(struct cec_adapter *adap);41void (*free)(struct cec_adapter *adap);42void (*status)(struct cec_adapter *adap, struct seq_file *file);43int (*read_hpd)(struct cec_adapter *adap);44int (*read_5v)(struct cec_adapter *adap);4546/* High-level CEC message callback */47int (*received)(struct cec_adapter *adap, struct cec_msg *msg);48};4950/**51* cec_pin_changed() - update pin state from interrupt52*53* @adap: pointer to the cec adapter54* @value: when true the pin is high, otherwise it is low55*56* If changes of the CEC voltage are detected via an interrupt, then57* cec_pin_changed is called from the interrupt with the new value.58*/59void cec_pin_changed(struct cec_adapter *adap, bool value);6061/**62* cec_pin_allocate_adapter() - allocate a pin-based cec adapter63*64* @pin_ops: low-level pin operations65* @priv: will be stored in adap->priv and can be used by the adapter ops.66* Use cec_get_drvdata(adap) to get the priv pointer.67* @name: the name of the CEC adapter. Note: this name will be copied.68* @caps: capabilities of the CEC adapter. This will be ORed with69* CEC_CAP_MONITOR_ALL and CEC_CAP_MONITOR_PIN.70*71* Allocate a cec adapter using the cec pin framework.72*73* Return: a pointer to the cec adapter or an error pointer74*/75struct cec_adapter *cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops,76void *priv, const char *name, u32 caps);7778#endif798081