linux/drivers/media/cec/core/cec-pin.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
 */

#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/sched/types.h>

#include <media/cec-pin.h>
#include "cec-pin-priv.h"

/* All timings are in microseconds */

/* start bit timings */
#define CEC_TIM_START_BIT_LOW
#define CEC_TIM_START_BIT_LOW_MIN
#define CEC_TIM_START_BIT_LOW_MAX
#define CEC_TIM_START_BIT_TOTAL
#define CEC_TIM_START_BIT_TOTAL_MIN
#define CEC_TIM_START_BIT_TOTAL_MAX

/* data bit timings */
#define CEC_TIM_DATA_BIT_0_LOW
#define CEC_TIM_DATA_BIT_0_LOW_MIN
#define CEC_TIM_DATA_BIT_0_LOW_MAX
#define CEC_TIM_DATA_BIT_1_LOW
#define CEC_TIM_DATA_BIT_1_LOW_MIN
#define CEC_TIM_DATA_BIT_1_LOW_MAX
#define CEC_TIM_DATA_BIT_TOTAL
#define CEC_TIM_DATA_BIT_TOTAL_MIN
#define CEC_TIM_DATA_BIT_TOTAL_MAX
/* earliest safe time to sample the bit state */
#define CEC_TIM_DATA_BIT_SAMPLE
/* earliest time the bit is back to 1 (T7 + 50) */
#define CEC_TIM_DATA_BIT_HIGH

/* when idle, sample once per millisecond */
#define CEC_TIM_IDLE_SAMPLE
/* when processing the start bit, sample twice per millisecond */
#define CEC_TIM_START_BIT_SAMPLE
/* when polling for a state change, sample once every 50 microseconds */
#define CEC_TIM_SAMPLE

#define CEC_TIM_LOW_DRIVE_ERROR

/*
 * Total data bit time that is too short/long for a valid bit,
 * used for error injection.
 */
#define CEC_TIM_DATA_BIT_TOTAL_SHORT
#define CEC_TIM_DATA_BIT_TOTAL_LONG

/*
 * Total start bit time that is too short/long for a valid bit,
 * used for error injection.
 */
#define CEC_TIM_START_BIT_TOTAL_SHORT
#define CEC_TIM_START_BIT_TOTAL_LONG

/* Data bits are 0-7, EOM is bit 8 and ACK is bit 9 */
#define EOM_BIT
#define ACK_BIT

struct cec_state {};

static const struct cec_state states[CEC_PIN_STATES] =;

static void cec_pin_update(struct cec_pin *pin, bool v, bool force)
{}

static bool cec_pin_read(struct cec_pin *pin)
{}

static void cec_pin_low(struct cec_pin *pin)
{}

static bool cec_pin_high(struct cec_pin *pin)
{}

static bool rx_error_inj(struct cec_pin *pin, unsigned int mode_offset,
			 int arg_idx, u8 *arg)
{}

static bool rx_nack(struct cec_pin *pin)
{}

static bool rx_low_drive(struct cec_pin *pin)
{}

static bool rx_add_byte(struct cec_pin *pin)
{}

static bool rx_remove_byte(struct cec_pin *pin)
{}

static bool rx_arb_lost(struct cec_pin *pin, u8 *poll)
{}

static bool tx_error_inj(struct cec_pin *pin, unsigned int mode_offset,
			 int arg_idx, u8 *arg)
{}

static bool tx_no_eom(struct cec_pin *pin)
{}

static bool tx_early_eom(struct cec_pin *pin)
{}

static bool tx_short_bit(struct cec_pin *pin)
{}

static bool tx_long_bit(struct cec_pin *pin)
{}

static bool tx_custom_bit(struct cec_pin *pin)
{}

static bool tx_short_start(struct cec_pin *pin)
{}

static bool tx_long_start(struct cec_pin *pin)
{}

static bool tx_custom_start(struct cec_pin *pin)
{}

static bool tx_last_bit(struct cec_pin *pin)
{}

static u8 tx_add_bytes(struct cec_pin *pin)
{}

static bool tx_remove_byte(struct cec_pin *pin)
{}

static bool tx_low_drive(struct cec_pin *pin)
{}

static void cec_pin_to_idle(struct cec_pin *pin)
{}

/*
 * Handle Transmit-related states
 *
 * Basic state changes when transmitting:
 *
 * Idle -> Tx Wait (waiting for the end of signal free time) ->
 *	Tx Start Bit Low -> Tx Start Bit High ->
 *
 *   Regular data bits + EOM:
 *	Tx Data 0 Low -> Tx Data 0 High ->
 *   or:
 *	Tx Data 1 Low -> Tx Data 1 High ->
 *
 *   First 4 data bits or Ack bit:
 *	Tx Data 0 Low -> Tx Data 0 High ->
 *   or:
 *	Tx Data 1 Low -> Tx Data 1 High -> Tx Data 1 Pre Sample ->
 *		Tx Data 1 Post Sample ->
 *
 *   After the last Ack go to Idle.
 *
 * If it detects a Low Drive condition then:
 *	Tx Wait For High -> Idle
 *
 * If it loses arbitration, then it switches to state Rx Data Post Sample.
 */
static void cec_pin_tx_states(struct cec_pin *pin, ktime_t ts)
{}

/*
 * Handle Receive-related states
 *
 * Basic state changes when receiving:
 *
 *	Rx Start Bit Low -> Rx Start Bit High ->
 *   Regular data bits + EOM:
 *	Rx Data Sample -> Rx Data Post Sample -> Rx Data High ->
 *   Ack bit 0:
 *	Rx Ack Low -> Rx Ack Low Post -> Rx Data High ->
 *   Ack bit 1:
 *	Rx Ack High Post -> Rx Data High ->
 *   Ack bit 0 && EOM:
 *	Rx Ack Low -> Rx Ack Low Post -> Rx Ack Finish -> Idle
 */
static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
{}

/*
 * Main timer function
 *
 */
static enum hrtimer_restart cec_pin_timer(struct hrtimer *timer)
{}

static int cec_pin_thread_func(void *_adap)
{}

static int cec_pin_adap_enable(struct cec_adapter *adap, bool enable)
{}

static int cec_pin_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
{}

void cec_pin_start_timer(struct cec_pin *pin)
{}

static int cec_pin_adap_transmit(struct cec_adapter *adap, u8 attempts,
				      u32 signal_free_time, struct cec_msg *msg)
{}

static void cec_pin_adap_status(struct cec_adapter *adap,
				       struct seq_file *file)
{}

static int cec_pin_adap_monitor_all_enable(struct cec_adapter *adap,
						  bool enable)
{}

static void cec_pin_adap_free(struct cec_adapter *adap)
{}

static int cec_pin_received(struct cec_adapter *adap, struct cec_msg *msg)
{}

void cec_pin_changed(struct cec_adapter *adap, bool value)
{}
EXPORT_SYMBOL_GPL();

static const struct cec_adap_ops cec_pin_adap_ops =;

struct cec_adapter *cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops,
					void *priv, const char *name, u32 caps)
{}
EXPORT_SYMBOL_GPL();