/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2021-2023 Val Packett <[email protected]>4* Copyright (c) 2023 Vladimir Kondratyev <[email protected]>5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#ifndef _ATOPCASE_REG_H_29#define _ATOPCASE_REG_H_3031#include <sys/types.h>3233#define ATOPCASE_PACKET_SIZE 25634#define ATOPCASE_DATA_SIZE 24635#define ATOPCASE_PKT_PER_MSG 236#define ATOPCASE_MSG_SIZE (ATOPCASE_DATA_SIZE * ATOPCASE_PKT_PER_MSG)3738/* Read == device-initiated, Write == host-initiated or reply to that */39#define ATOPCASE_DIR_READ 0x2040#define ATOPCASE_DIR_WRITE 0x4041#define ATOPCASE_DIR_NOTHING 0x804243#define ATOPCASE_DEV_MGMT 0x0044#define ATOPCASE_DEV_KBRD 0x0145#define ATOPCASE_DEV_TPAD 0x0246#define ATOPCASE_DEV_INFO 0xD04748#define ATOPCASE_BKL_REPORT_ID 0xB04950#define ATOPCASE_INFO_DEVICE 0x0151#define ATOPCASE_INFO_IFACE 0x0252#define ATOPCASE_INFO_DESCRIPTOR 0x105354#define ATOPCASE_MSG_TYPE_SET_REPORT(dev,rid) ((rid << 8) | 0x50 | dev)55#define ATOPCASE_MSG_TYPE_REPORT(dev) ((dev << 8) | 0x10)56#define ATOPCASE_MSG_TYPE_INFO(inf) ((inf << 8) | 0x20)5758struct atopcase_bl_payload {59uint8_t report_id;60uint8_t device;61uint16_t level;62uint16_t status;63} __packed;6465struct atopcase_device_info_payload {66uint16_t unknown[2];67uint16_t num_devs;68uint16_t vid;69uint16_t pid;70uint16_t ver;71uint16_t vendor_off;72uint16_t vendor_len;73uint16_t product_off;74uint16_t product_len;75uint16_t serial_off;76uint16_t serial_len;77} __packed;7879struct atopcase_iface_info_payload {80uint8_t unknown0;81uint8_t iface_num;82uint8_t unknown1[3];83uint8_t country_code;84uint16_t max_input_report_len;85uint16_t max_output_report_len;86uint16_t max_control_report_len;87uint16_t name_off;88uint16_t name_len;89} __packed;9091struct atopcase_header {92uint16_t type;93uint8_t type_arg; /* means "device" for ATOPCASE_MSG_TYPE_DESCRIPTOR */94uint8_t seq_no;95uint16_t resp_len;96uint16_t len;97} __packed;9899struct atopcase_packet {100uint8_t direction;101uint8_t device;102uint16_t offset;103uint16_t remaining;104uint16_t length;105uint8_t data[ATOPCASE_DATA_SIZE];106uint16_t checksum;107} __packed;108109#endif /* _ATOPCASE_REG_H_ */110111112