linux/drivers/media/pci/cx23885/cx23888-ir.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  Driver for the Conexant CX23885/7/8 PCIe bridge
 *
 *  CX23888 Integrated Consumer Infrared Controller
 *
 *  Copyright (C) 2009  Andy Walls <[email protected]>
 */

#include "cx23885.h"
#include "cx23888-ir.h"

#include <linux/kfifo.h>
#include <linux/slab.h>

#include <media/v4l2-device.h>
#include <media/rc-core.h>

static unsigned int ir_888_debug;
module_param(ir_888_debug, int, 0644);
MODULE_PARM_DESC();

#define CX23888_IR_REG_BASE
/*
 * These CX23888 register offsets have a straightforward one to one mapping
 * to the CX23885 register offsets of 0x200 through 0x218
 */
#define CX23888_IR_CNTRL_REG
#define CNTRL_WIN_3_3
#define CNTRL_WIN_4_3
#define CNTRL_WIN_3_4
#define CNTRL_WIN_4_4
#define CNTRL_WIN
#define CNTRL_EDG_NONE
#define CNTRL_EDG_FALL
#define CNTRL_EDG_RISE
#define CNTRL_EDG_BOTH
#define CNTRL_EDG
#define CNTRL_DMD
#define CNTRL_MOD
#define CNTRL_RFE
#define CNTRL_TFE
#define CNTRL_RXE
#define CNTRL_TXE
#define CNTRL_RIC
#define CNTRL_TIC
#define CNTRL_CPL
#define CNTRL_LBM
#define CNTRL_R
/* CX23888 specific control flag */
#define CNTRL_IVO

#define CX23888_IR_TXCLK_REG
#define TXCLK_TCD

#define CX23888_IR_RXCLK_REG
#define RXCLK_RCD

#define CX23888_IR_CDUTY_REG
#define CDUTY_CDC

#define CX23888_IR_STATS_REG
#define STATS_RTO
#define STATS_ROR
#define STATS_RBY
#define STATS_TBY
#define STATS_RSR
#define STATS_TSR

#define CX23888_IR_IRQEN_REG
#define IRQEN_RTE
#define IRQEN_ROE
#define IRQEN_RSE
#define IRQEN_TSE

#define CX23888_IR_FILTR_REG
#define FILTR_LPF

/* This register doesn't follow the pattern; it's 0x23C on a CX23885 */
#define CX23888_IR_FIFO_REG
#define FIFO_RXTX
#define FIFO_RXTX_LVL
#define FIFO_RXTX_RTO
#define FIFO_RX_NDV
#define FIFO_RX_DEPTH
#define FIFO_TX_DEPTH

/* CX23888 unique registers */
#define CX23888_IR_SEEDP_REG
#define CX23888_IR_TIMOL_REG
#define CX23888_IR_WAKE0_REG
#define CX23888_IR_WAKE1_REG
#define CX23888_IR_WAKE2_REG
#define CX23888_IR_MASK0_REG
#define CX23888_IR_MASK1_REG
#define CX23888_IR_MAKS2_REG
#define CX23888_IR_DPIPG_REG
#define CX23888_IR_LEARN_REG

#define CX23888_VIDCLK_FREQ
#define CX23888_IR_REFCLK_FREQ

/*
 * We use this union internally for convenience, but callers to tx_write
 * and rx_read will be expecting records of type struct ir_raw_event.
 * Always ensure the size of this union is dictated by struct ir_raw_event.
 */
cx23888_ir_fifo_rec;

#define CX23888_IR_RX_KFIFO_SIZE
#define CX23888_IR_TX_KFIFO_SIZE

struct cx23888_ir_state {};

static inline struct cx23888_ir_state *to_state(struct v4l2_subdev *sd)
{}

/*
 * IR register block read and write functions
 */
static
inline int cx23888_ir_write4(struct cx23885_dev *dev, u32 addr, u32 value)
{}

static inline u32 cx23888_ir_read4(struct cx23885_dev *dev, u32 addr)
{}

static inline int cx23888_ir_and_or4(struct cx23885_dev *dev, u32 addr,
				     u32 and_mask, u32 or_value)
{}

/*
 * Rx and Tx Clock Divider register computations
 *
 * Note the largest clock divider value of 0xffff corresponds to:
 *	(0xffff + 1) * 1000 / 108/2 MHz = 1,213,629.629... ns
 * which fits in 21 bits, so we'll use unsigned int for time arguments.
 */
static inline u16 count_to_clock_divider(unsigned int d)
{}

static inline u16 carrier_freq_to_clock_divider(unsigned int freq)
{}

static inline unsigned int clock_divider_to_carrier_freq(unsigned int divider)
{}

static inline unsigned int clock_divider_to_freq(unsigned int divider,
						 unsigned int rollovers)
{}

/*
 * Low Pass Filter register calculations
 *
 * Note the largest count value of 0xffff corresponds to:
 *	0xffff * 1000 / 108/2 MHz = 1,213,611.11... ns
 * which fits in 21 bits, so we'll use unsigned int for time arguments.
 */
static inline u16 count_to_lpf_count(unsigned int d)
{}

static inline u16 ns_to_lpf_count(unsigned int ns)
{}

static inline unsigned int lpf_count_to_ns(unsigned int count)
{}

static inline unsigned int lpf_count_to_us(unsigned int count)
{}

/*
 * FIFO register pulse width count computations
 */
static u32 clock_divider_to_resolution(u16 divider)
{}

static u64 pulse_width_count_to_ns(u16 count, u16 divider)
{}

static unsigned int pulse_width_count_to_us(u16 count, u16 divider)
{}

/*
 * Pulse Clocks computations: Combined Pulse Width Count & Rx Clock Counts
 *
 * The total pulse clock count is an 18 bit pulse width timer count as the most
 * significant part and (up to) 16 bit clock divider count as a modulus.
 * When the Rx clock divider ticks down to 0, it increments the 18 bit pulse
 * width timer count's least significant bit.
 */
static u64 ns_to_pulse_clocks(u32 ns)
{}

static u16 pulse_clocks_to_clock_divider(u64 count)
{}

/*
 * IR Control Register helpers
 */
enum tx_fifo_watermark {};

enum rx_fifo_watermark {};

static inline void control_tx_irq_watermark(struct cx23885_dev *dev,
					    enum tx_fifo_watermark level)
{}

static inline void control_rx_irq_watermark(struct cx23885_dev *dev,
					    enum rx_fifo_watermark level)
{}

static inline void control_tx_enable(struct cx23885_dev *dev, bool enable)
{}

static inline void control_rx_enable(struct cx23885_dev *dev, bool enable)
{}

static inline void control_tx_modulation_enable(struct cx23885_dev *dev,
						bool enable)
{}

static inline void control_rx_demodulation_enable(struct cx23885_dev *dev,
						  bool enable)
{}

static inline void control_rx_s_edge_detection(struct cx23885_dev *dev,
					       u32 edge_types)
{}

static void control_rx_s_carrier_window(struct cx23885_dev *dev,
					unsigned int carrier,
					unsigned int *carrier_range_low,
					unsigned int *carrier_range_high)
{}

static inline void control_tx_polarity_invert(struct cx23885_dev *dev,
					      bool invert)
{}

static inline void control_tx_level_invert(struct cx23885_dev *dev,
					  bool invert)
{}

/*
 * IR Rx & Tx Clock Register helpers
 */
static unsigned int txclk_tx_s_carrier(struct cx23885_dev *dev,
				       unsigned int freq,
				       u16 *divider)
{}

static unsigned int rxclk_rx_s_carrier(struct cx23885_dev *dev,
				       unsigned int freq,
				       u16 *divider)
{}

static u32 txclk_tx_s_max_pulse_width(struct cx23885_dev *dev, u32 ns,
				      u16 *divider)
{}

static u32 rxclk_rx_s_max_pulse_width(struct cx23885_dev *dev, u32 ns,
				      u16 *divider)
{}

/*
 * IR Tx Carrier Duty Cycle register helpers
 */
static unsigned int cduty_tx_s_duty_cycle(struct cx23885_dev *dev,
					  unsigned int duty_cycle)
{}

/*
 * IR Filter Register helpers
 */
static u32 filter_rx_s_min_width(struct cx23885_dev *dev, u32 min_width_ns)
{}

/*
 * IR IRQ Enable Register helpers
 */
static inline void irqenable_rx(struct cx23885_dev *dev, u32 mask)
{}

static inline void irqenable_tx(struct cx23885_dev *dev, u32 mask)
{}

/*
 * V4L2 Subdevice IR Ops
 */
static int cx23888_ir_irq_handler(struct v4l2_subdev *sd, u32 status,
				  bool *handled)
{}

/* Receiver */
static int cx23888_ir_rx_read(struct v4l2_subdev *sd, u8 *buf, size_t count,
			      ssize_t *num)
{}

static int cx23888_ir_rx_g_parameters(struct v4l2_subdev *sd,
				      struct v4l2_subdev_ir_parameters *p)
{}

static int cx23888_ir_rx_shutdown(struct v4l2_subdev *sd)
{}

static int cx23888_ir_rx_s_parameters(struct v4l2_subdev *sd,
				      struct v4l2_subdev_ir_parameters *p)
{}

/* Transmitter */
static int cx23888_ir_tx_write(struct v4l2_subdev *sd, u8 *buf, size_t count,
			       ssize_t *num)
{}

static int cx23888_ir_tx_g_parameters(struct v4l2_subdev *sd,
				      struct v4l2_subdev_ir_parameters *p)
{}

static int cx23888_ir_tx_shutdown(struct v4l2_subdev *sd)
{}

static int cx23888_ir_tx_s_parameters(struct v4l2_subdev *sd,
				      struct v4l2_subdev_ir_parameters *p)
{}


/*
 * V4L2 Subdevice Core Ops
 */
static int cx23888_ir_log_status(struct v4l2_subdev *sd)
{}

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int cx23888_ir_g_register(struct v4l2_subdev *sd,
				 struct v4l2_dbg_register *reg)
{}

static int cx23888_ir_s_register(struct v4l2_subdev *sd,
				 const struct v4l2_dbg_register *reg)
{}
#endif

static const struct v4l2_subdev_core_ops cx23888_ir_core_ops =;

static const struct v4l2_subdev_ir_ops cx23888_ir_ir_ops =;

static const struct v4l2_subdev_ops cx23888_ir_controller_ops =;

static const struct v4l2_subdev_ir_parameters default_rx_params =;

static const struct v4l2_subdev_ir_parameters default_tx_params =;

int cx23888_ir_probe(struct cx23885_dev *dev)
{}

int cx23888_ir_remove(struct cx23885_dev *dev)
{}