1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Copyright 2021-2024 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
7 #ifndef _EXTRON_DA_HD_4K_PLUS_H_
8 #define _EXTRON_DA_HD_4K_PLUS_H_
10 #include <linux/kthread.h>
11 #include <linux/serio.h>
12 #include <linux/workqueue.h>
13 #include <media/cec.h>
14 #include <media/v4l2-ctrls.h>
15 #include <media/v4l2-dev.h>
16 #include <media/v4l2-device.h>
17 #include <media/v4l2-dv-timings.h>
18 #include <media/v4l2-event.h>
19 #include <media/v4l2-fh.h>
20 #include <media/v4l2-ioctl.h>
22 #include "cec-splitter.h"
26 #define PING_PERIOD (15 * HZ)
28 #define NUM_MSGS CEC_MAX_MSG_RX_QUEUE_SZ
30 #define MAX_PORTS (1 + 6)
32 #define MAX_EDID_BLOCKS 2
37 struct cec_splitter_port port
;
39 struct cec_adapter
*adap
;
40 struct video_device vdev
;
41 struct v4l2_ctrl_handler hdl
;
42 struct v4l2_ctrl
*ctrl_rx_power_present
;
43 struct v4l2_ctrl
*ctrl_tx_hotplug
;
44 struct v4l2_ctrl
*ctrl_tx_edid_present
;
48 unsigned char edid
[MAX_EDID_BLOCKS
* 128];
49 unsigned char edid_tmp
[MAX_EDID_BLOCKS
* 128];
50 unsigned int edid_blocks
;
52 struct extron
*extron
;
53 struct work_struct irq_work
;
54 struct completion cmd_done
;
56 unsigned int cmd_error
;
57 struct cec_msg rx_msg
[NUM_MSGS
];
58 unsigned int rx_msg_cur_idx
, rx_msg_num
;
59 /* protect rx_msg_cur_idx and rx_msg_num */
62 bool update_phys_addr
;
64 bool cec_was_registered
;
66 bool update_has_signal
;
76 /* locks access to the video_device */
77 struct mutex video_lock
;
81 struct cec_splitter splitter
;
84 /* locks access to serio */
85 struct mutex serio_lock
;
86 unsigned int num_ports
;
87 unsigned int num_in_ports
;
88 unsigned int num_out_ports
;
91 char unit_fw_version
[32];
92 char unit_cec_engine_version
[32];
93 struct extron_port
*ports
[MAX_PORTS
];
94 struct cec_splitter_port
*splitter_ports
[MAX_PORTS
];
95 struct v4l2_device v4l2_dev
;
97 struct task_struct
*kthread_setup
;
98 struct delayed_work work_update_edid
;
100 /* serializes EDID reading */
101 struct mutex edid_lock
;
102 unsigned int edid_bytes_read
;
103 struct extron_port
*edid_port
;
104 struct completion edid_completion
;
108 struct completion cmd_done
;
109 const char *response
;
110 unsigned int cmd_error
;
111 char data
[DATA_SIZE
];
113 char reply
[DATA_SIZE
];