1*056f2821SHans Verkuil /* SPDX-License-Identifier: GPL-2.0-only */ 2*056f2821SHans Verkuil 3*056f2821SHans Verkuil /* 4*056f2821SHans Verkuil * Copyright 2021-2024 Cisco Systems, Inc. and/or its affiliates. All rights reserved. 5*056f2821SHans Verkuil */ 6*056f2821SHans Verkuil 7*056f2821SHans Verkuil #ifndef _EXTRON_DA_HD_4K_PLUS_H_ 8*056f2821SHans Verkuil #define _EXTRON_DA_HD_4K_PLUS_H_ 9*056f2821SHans Verkuil 10*056f2821SHans Verkuil #include <linux/kthread.h> 11*056f2821SHans Verkuil #include <linux/serio.h> 12*056f2821SHans Verkuil #include <linux/workqueue.h> 13*056f2821SHans Verkuil #include <media/cec.h> 14*056f2821SHans Verkuil #include <media/v4l2-ctrls.h> 15*056f2821SHans Verkuil #include <media/v4l2-dev.h> 16*056f2821SHans Verkuil #include <media/v4l2-device.h> 17*056f2821SHans Verkuil #include <media/v4l2-dv-timings.h> 18*056f2821SHans Verkuil #include <media/v4l2-event.h> 19*056f2821SHans Verkuil #include <media/v4l2-fh.h> 20*056f2821SHans Verkuil #include <media/v4l2-ioctl.h> 21*056f2821SHans Verkuil 22*056f2821SHans Verkuil #include "cec-splitter.h" 23*056f2821SHans Verkuil 24*056f2821SHans Verkuil #define DATA_SIZE 256 25*056f2821SHans Verkuil 26*056f2821SHans Verkuil #define PING_PERIOD (15 * HZ) 27*056f2821SHans Verkuil 28*056f2821SHans Verkuil #define NUM_MSGS CEC_MAX_MSG_RX_QUEUE_SZ 29*056f2821SHans Verkuil 30*056f2821SHans Verkuil #define MAX_PORTS (1 + 6) 31*056f2821SHans Verkuil 32*056f2821SHans Verkuil #define MAX_EDID_BLOCKS 2 33*056f2821SHans Verkuil 34*056f2821SHans Verkuil struct extron; 35*056f2821SHans Verkuil 36*056f2821SHans Verkuil struct extron_port { 37*056f2821SHans Verkuil struct cec_splitter_port port; 38*056f2821SHans Verkuil struct device *dev; 39*056f2821SHans Verkuil struct cec_adapter *adap; 40*056f2821SHans Verkuil struct video_device vdev; 41*056f2821SHans Verkuil struct v4l2_ctrl_handler hdl; 42*056f2821SHans Verkuil struct v4l2_ctrl *ctrl_rx_power_present; 43*056f2821SHans Verkuil struct v4l2_ctrl *ctrl_tx_hotplug; 44*056f2821SHans Verkuil struct v4l2_ctrl *ctrl_tx_edid_present; 45*056f2821SHans Verkuil bool is_input; 46*056f2821SHans Verkuil char direction; 47*056f2821SHans Verkuil char name[26]; 48*056f2821SHans Verkuil unsigned char edid[MAX_EDID_BLOCKS * 128]; 49*056f2821SHans Verkuil unsigned char edid_tmp[MAX_EDID_BLOCKS * 128]; 50*056f2821SHans Verkuil unsigned int edid_blocks; 51*056f2821SHans Verkuil bool read_edid; 52*056f2821SHans Verkuil struct extron *extron; 53*056f2821SHans Verkuil struct work_struct irq_work; 54*056f2821SHans Verkuil struct completion cmd_done; 55*056f2821SHans Verkuil const char *response; 56*056f2821SHans Verkuil unsigned int cmd_error; 57*056f2821SHans Verkuil struct cec_msg rx_msg[NUM_MSGS]; 58*056f2821SHans Verkuil unsigned int rx_msg_cur_idx, rx_msg_num; 59*056f2821SHans Verkuil /* protect rx_msg_cur_idx and rx_msg_num */ 60*056f2821SHans Verkuil spinlock_t msg_lock; 61*056f2821SHans Verkuil u32 tx_done_status; 62*056f2821SHans Verkuil bool update_phys_addr; 63*056f2821SHans Verkuil u16 phys_addr; 64*056f2821SHans Verkuil bool cec_was_registered; 65*056f2821SHans Verkuil bool disconnected; 66*056f2821SHans Verkuil bool update_has_signal; 67*056f2821SHans Verkuil bool has_signal; 68*056f2821SHans Verkuil bool update_has_edid; 69*056f2821SHans Verkuil bool has_edid; 70*056f2821SHans Verkuil bool has_4kp30; 71*056f2821SHans Verkuil bool has_4kp60; 72*056f2821SHans Verkuil bool has_qy; 73*056f2821SHans Verkuil bool has_qs; 74*056f2821SHans Verkuil u8 est_i, est_ii; 75*056f2821SHans Verkuil 76*056f2821SHans Verkuil /* locks access to the video_device */ 77*056f2821SHans Verkuil struct mutex video_lock; 78*056f2821SHans Verkuil }; 79*056f2821SHans Verkuil 80*056f2821SHans Verkuil struct extron { 81*056f2821SHans Verkuil struct cec_splitter splitter; 82*056f2821SHans Verkuil struct device *dev; 83*056f2821SHans Verkuil struct serio *serio; 84*056f2821SHans Verkuil /* locks access to serio */ 85*056f2821SHans Verkuil struct mutex serio_lock; 86*056f2821SHans Verkuil unsigned int num_ports; 87*056f2821SHans Verkuil unsigned int num_in_ports; 88*056f2821SHans Verkuil unsigned int num_out_ports; 89*056f2821SHans Verkuil char unit_name[32]; 90*056f2821SHans Verkuil char unit_type[64]; 91*056f2821SHans Verkuil char unit_fw_version[32]; 92*056f2821SHans Verkuil char unit_cec_engine_version[32]; 93*056f2821SHans Verkuil struct extron_port *ports[MAX_PORTS]; 94*056f2821SHans Verkuil struct cec_splitter_port *splitter_ports[MAX_PORTS]; 95*056f2821SHans Verkuil struct v4l2_device v4l2_dev; 96*056f2821SHans Verkuil bool hpd_never_low; 97*056f2821SHans Verkuil struct task_struct *kthread_setup; 98*056f2821SHans Verkuil struct delayed_work work_update_edid; 99*056f2821SHans Verkuil 100*056f2821SHans Verkuil /* serializes EDID reading */ 101*056f2821SHans Verkuil struct mutex edid_lock; 102*056f2821SHans Verkuil unsigned int edid_bytes_read; 103*056f2821SHans Verkuil struct extron_port *edid_port; 104*056f2821SHans Verkuil struct completion edid_completion; 105*056f2821SHans Verkuil bool edid_reading; 106*056f2821SHans Verkuil bool is_ready; 107*056f2821SHans Verkuil 108*056f2821SHans Verkuil struct completion cmd_done; 109*056f2821SHans Verkuil const char *response; 110*056f2821SHans Verkuil unsigned int cmd_error; 111*056f2821SHans Verkuil char data[DATA_SIZE]; 112*056f2821SHans Verkuil unsigned int len; 113*056f2821SHans Verkuil char reply[DATA_SIZE]; 114*056f2821SHans Verkuil char buf[DATA_SIZE]; 115*056f2821SHans Verkuil unsigned int idx; 116*056f2821SHans Verkuil }; 117*056f2821SHans Verkuil 118*056f2821SHans Verkuil #endif 119