RK3399 android10 移植SiS-USB触摸驱动

一,SiS USB触摸简介

SiS USB 触摸屏通常是一种外接式触摸屏设备,通过 USB 接口连接到计算机或其他设备上。这种触摸屏设备可以提供触摸输入功能,用户可以通过手指或触控笔在屏幕上进行操作,实现点击、拖动、缩放等操作。
SiS USB 触摸屏通常需要安装相应的驱动程序才能正常工作,在计算机系统中被识别为触摸输入设备。驱动程序会将触摸屏输入转换为计算机可识别的信号,从而实现触摸屏在操作系统中的正常使用。


二,驱动文件配置

1. hid_sis内核模块驱动文件

在这里插入图片描述

hid-sis_ctrl.c :在Linux内核中,HID设备驱动程序负责与各种输入设备(如键盘、鼠标、游戏手柄等)进行通信和管理。包含与特定类型的HID设备通信的代码实现,包括设备的初始化、数据传输、事件处理等功能。这个文件可能会被编译到内核中,以便在系统启动时加载并与相应的HID设备进行交互。

/**  Character device driver for SIS multitouch panels control**  Copyright (c) 2023 SIS, Ltd.**//** This program is free software; you can redistribute it and/or modify it* under the terms of the GNU General Public License as published by the Free* Software Foundation; either version 2 of the License, or (at your option)* any later version.*/#include <linux/hid.h>
#include <linux/module.h>
#include <linux/usb.h>
#include "usbhid/usbhid.h"
#include <linux/init.h>//update FW
#include <linux/fs.h>
#include <linux/cdev.h>
#include <asm/uaccess.h>				//copy_from_user() & copy_to_user()#include "hid-ids.h"
#include "hid-sis_ctrl.h"static int sis_char_devs_count = 1;        		/* device count */
static int sis_char_major = 0;
static struct cdev sis_char_cdev;
static struct class *sis_char_class = NULL;static struct hid_device *hid_dev_backup = NULL;	//backup address
static struct urb *backup_urb = NULL;#define	REPORTID_21_LEN	64
#define	REPORTID_25_LEN	320
#define	REPORTID_29_LEN	576
#define	REPORTID_2D_LEN	832#ifdef CONFIG_DEBUG_HID_SIS_UPDATE_FW#define DBG_FW(fmt, arg...)	printk( fmt, ##arg )void sis_dbg_dump_array( u8 *ptr, u32 size){u32 i;for (i=0; i<size; i++)  {DBG_FW ("%02X ", ptr[i]);if( ((i+1)&0xF) == 0)DBG_FW ("\n");}if( size & 0xF)DBG_FW ("\n");}
#else#define DBG_FW(...)#define sis_dbg_dump_array(...)
#endif	// CONFIG_DEBUG_HID_SIS_UPDATE_FWint sis_cdev_open(struct inode *inode, struct file *filp)	//20120306 Yuger ioctl for tool
{struct usbhid_device *usbhid; DBG_FW( "%s\n" , __FUNCTION__ );//20110511, Yuger, kill current urb by method of usbhid_stopif ( !hid_dev_backup ){printk( KERN_INFO "(stop)hid_dev_backup is not initialized yet" );return -1;}usbhid = hid_dev_backup->driver_data;printk( KERN_INFO "sys_sis_HID_stop\n" );//printk( KERN_INFO "hid_dev_backup->vendor, hid_dev_backup->product = %x %x\n", hid_dev_backup->vendor, hid_dev_backup->product );//20110602, Yuger, fix bug: not contact usb cause kernel panicif( !usbhid ){printk( KERN_INFO "(stop)usbhid is not initialized yet" );return -1;}else if ( !usbhid->urbin ){printk( KERN_INFO "(stop)usbhid->urbin is not initialized yet" );return -1;}else if (hid_dev_backup->vendor == USB_VENDOR_ID_SIS_TOUCH){usb_fill_int_urb(backup_urb, usbhid->urbin->dev, usbhid->urbin->pipe,usbhid->urbin->transfer_buffer, usbhid->urbin->transfer_buffer_length,usbhid->urbin->complete, usbhid->urbin->context, usbhid->urbin->interval);clear_bit( HID_STARTED, &usbhid->iofl );set_bit( HID_DISCONNECTED, &usbhid->iofl );usb_kill_urb( usbhid->urbin );usb_free_urb( usbhid->urbin );usbhid->urbin = NULL;return 0;}else	{printk (KERN_INFO "This is not a SiS device");return -801;}
}int sis_cdev_release(struct inode *inode, struct file *filp)
{//20110505, Yuger, rebuild the urb which is at the same urb address, then re-submit itint ret;struct usbhid_device *usbhid;unsigned long flags;DBG_FW( "%s: " , __FUNCTION__ );if ( !hid_dev_backup ){printk( KERN_INFO "(stop)hid_dev_backup is not initialized yet" );return -1;}usbhid = hid_dev_backup->driver_data;printk( KERN_INFO "sys_sis_HID_start" );if( !usbhid ){printk( KERN_INFO "(start)usbhid is not initialized yet" );return -1;}if( !backup_urb ){printk( KERN_INFO "(start)backup_urb is not initialized yet" );return -1;}clear_bit( HID_DISCONNECTED, &usbhid->iofl );usbhid->urbin = usb_alloc_urb( 0, GFP_KERNEL );if( !backup_urb->interval ){printk( KERN_INFO "(start)backup_urb->interval does not exist" );return -1;}usb_fill_int_urb(usbhid->urbin, backup_urb->dev, backup_urb->pipe, backup_urb->transfer_buffer, backup_urb->transfer_buffer_length, backup_urb->complete, backup_urb->context, backup_urb->interval);usbhid->urbin->transfer_dma = usbhid->inbuf_dma;usbhid->urbin->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;set_bit( HID_STARTED, &usbhid->iofl );//method at hid_start_inspin_lock_irqsave( &usbhid->lock, flags );		ret = usb_submit_urb( usbhid->urbin, GFP_ATOMIC );spin_unlock_irqrestore( &usbhid->lock, flags );//yyDBG_FW( "ret = %d", ret );return ret;
}ssize_t sis_cdev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{int timeout = 0;u8 *rep_data = NULL;u8 *temp_data = NULL;u16 size = 0;long rep_ret;struct usb_interface *intf = to_usb_interface(hid_dev_backup->dev.parent);struct usb_device *dev = interface_to_usbdev(intf);
#if IS_ENABLED(CONFIG_HID_SIS95XX_SIS98XX)u16 reportID = 0;
#elseint actual_length = 0;
#endifDBG_FW( "%s\n", __FUNCTION__ );temp_data = kzalloc(count, GFP_KERNEL);if(!temp_data) {printk( KERN_INFO "kzalloc temp_data fail\n");return (-12);}if ( copy_from_user( temp_data, (void*)buf, count) ) {printk( KERN_INFO "copy_from_user(temp_data) fail\n" );//free allocated datakfree( temp_data );temp_data = NULL;return -19;}#if IS_ENABLED(CONFIG_HID_SIS95XX_SIS98XX)switch (temp_data[0]) {case 0x21:size = (((u16)(temp_data[REPORTID_21_LEN] & 0xff)) << 24)+ (((u16)(temp_data[REPORTID_21_LEN + 1] & 0xff)) << 16)+ (((u16)(temp_data[REPORTID_21_LEN + 2] & 0xff)) << 8)+ (u16)(temp_data[REPORTID_21_LEN + 3] & 0xff);timeout = (((int)(temp_data[REPORTID_21_LEN + 4] & 0xff)) << 24)+ (((int)(temp_data[REPORTID_21_LEN + 5] & 0xff)) << 16)+ (((int)(temp_data[REPORTID_21_LEN + 6 ] & 0xff)) << 8)+ (int)(temp_data[REPORTID_21_LEN + 7] & 0xff);reportID = 0x0321;DBG_FW("%s Report ID : 0x21\n" , __FUNCTION__);break;case 0x25:size = (((u16)(temp_data[REPORTID_25_LEN] & 0xff)) << 24)+ (((u16)(temp_data[REPORTID_25_LEN + 1] & 0xff)) << 16)+ (((u16)(temp_data[REPORTID_25_LEN + 2] & 0xff)) << 8)+ (u16)(temp_data[REPORTID_25_LEN + 3] & 0xff);timeout = (((int)(temp_data[REPORTID_25_LEN + 4] & 0xff)) << 24)+ (((int)(temp_data[REPORTID_25_LEN + 5] & 0xff)) << 16)+ (((int)(temp_data[REPORTID_25_LEN + 6 ] & 0xff)) << 8)+ (int)(temp_data[REPORTID_25_LEN + 7] & 0xff);reportID = 0x0325;DBG_FW("%s Report ID : 0x25\n" , __FUNCTION__);break;case 0x29:size = (((u16)(temp_data[REPORTID_29_LEN] & 0xff)) << 24)+ (((u16)(temp_data[REPORTID_29_LEN + 1] & 0xff)) << 16)+ (((u16)(temp_data[REPORTID_29_LEN + 2] & 0xff)) << 8)+ (u16)(temp_data[REPORTID_29_LEN + 3] & 0xff);timeout = (((int)(temp_data[REPORTID_29_LEN + 4] & 0xff)) << 24)+ (((int)(temp_data[REPORTID_29_LEN + 5] & 0xff)) << 16)+ (((int)(temp_data[REPORTID_29_LEN + 6 ] & 0xff)) << 8)+ (int)(temp_data[REPORTID_29_LEN + 7] & 0xff);reportID = 0x0329;DBG_FW("%s Report ID : 0x29\n" , __FUNCTION__);break;case 0x2d:size = (((u16)(temp_data[REPORTID_2D_LEN] & 0xff)) << 24)+ (((u16)(temp_data[REPORTID_2D_LEN + 1] & 0xff)) << 16)+ (((u16)(temp_data[REPORTID_2D_LEN + 2] & 0xff)) << 8)+ (u16)(temp_data[REPORTID_2D_LEN + 3] & 0xff);timeout = (((int)(temp_data[REPORTID_2D_LEN + 4] & 0xff)) << 24)+ (((int)(temp_data[REPORTID_2D_LEN + 5] & 0xff)) << 16)+ (((int)(temp_data[REPORTID_2D_LEN + 6 ] & 0xff)) << 8)+ (int)(temp_data[REPORTID_2D_LEN + 7] & 0xff);reportID = 0x032d;DBG_FW( "%s Report ID : 0x2d\n" , __FUNCTION__ );break;default:break;}
#elsesize = (((u16)(temp_data[64] & 0xff)) << 24) + (((u16)(temp_data[65] & 0xff)) << 16) + (((u16)(temp_data[66] & 0xff)) << 8) + (u16)(temp_data[67] & 0xff);timeout = (((int)(temp_data[68] & 0xff)) << 24) + (((int)(temp_data[69] & 0xff)) << 16) + (((int)(temp_data[70] & 0xff)) << 8) + (int)(temp_data[71] & 0xff);DBG_FW("%s Report ID : 0x0a\n" , __FUNCTION__);	
#endifkfree(temp_data);temp_data = NULL;DBG_FW("timeout = %d, size %d\n", timeout, size);#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)if (!access_ok(VERIFY_WRITE, buf, size)) {
#elseif (!access_ok(buf, size)) {
#endifprintk(KERN_INFO "cannot access user space memory\n");return -11;}rep_data = kzalloc(size, GFP_KERNEL);if (!rep_data) {printk(KERN_INFO "kzalloc rep_data fail\n");return -12;}if (copy_from_user(rep_data, (void*)buf, size)) {printk(KERN_INFO "copy_to_user fail(rep_data)\n");//free allocated datakfree(rep_data);rep_data = NULL;return -19;}#if IS_ENABLED(CONFIG_HID_SIS95XX_SIS98XX)rep_ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x01, (USB_DIR_IN|USB_TYPE_CLASS|USB_RECIP_INTERFACE), reportID, 0, rep_data, size, timeout);DBG_FW("%s: rep_data = ", __FUNCTION__);sis_dbg_dump_array(rep_data, 8);if (copy_to_user((void*)buf, rep_data, rep_ret)) {printk(KERN_INFO "copy_to_user fail(buf)\n");//free allocated datakfree(rep_data);rep_data = NULL;return -19;}
#elserep_ret = usb_interrupt_msg(dev, backup_urb->pipe,rep_data, size, &actual_length, timeout);DBG_FW("%s: rep_data = ", __FUNCTION__);sis_dbg_dump_array(rep_data, 8);if (rep_ret == 0) {if (copy_to_user((void*)buf, rep_data, actual_length)) {printk(KERN_INFO "copy_to_user fail(buf)\n");//free allocated datakfree(rep_data);rep_data = NULL;return -19;}}
#endif//free allocated datakfree(rep_data);rep_data = NULL;DBG_FW("%s: rep_ret = %ld\n", __FUNCTION__, rep_ret);return rep_ret;
}ssize_t sis_cdev_write(struct file *file, const char __user *buf, size_t count, loff_t *f_pos)
{int timeout = 0;u8 *rep_data = NULL;u8 *temp_data = NULL;u16 size = 0;long rep_ret;struct usb_interface *intf = to_usb_interface(hid_dev_backup->dev.parent);struct usb_device *dev = interface_to_usbdev(intf);
#if IS_ENABLED(CONFIG_HID_SIS95XX_SIS98XX)u16 reportID = 0;
#elseint actual_length = 0;struct usbhid_device *usbhid = hid_dev_backup->driver_data;
#endifDBG_FW( "%s\n", __FUNCTION__ );temp_data = kzalloc(count, GFP_KERNEL);if(!temp_data){printk( KERN_INFO "kzalloc temp_data fail\n");return (-12);}if ( copy_from_user( temp_data, (void*)buf, count) ) {printk( KERN_INFO "copy_from_user(temp_data) fail\n" );//free allocated datakfree( temp_data );temp_data = NULL;return -19;}#if IS_ENABLED(CONFIG_HID_SIS95XX_SIS98XX)switch (temp_data[0]) {case 0x21:size = (((u16)(temp_data[REPORTID_21_LEN] & 0xff)) << 24)+ (((u16)(temp_data[REPORTID_21_LEN + 1] & 0xff)) << 16)+ (((u16)(temp_data[REPORTID_21_LEN + 2] & 0xff)) << 8)+ (u16)(temp_data[REPORTID_21_LEN + 3] & 0xff);timeout = (((int)(temp_data[REPORTID_21_LEN + 4] & 0xff)) << 24)+ (((int)(temp_data[REPORTID_21_LEN + 5] & 0xff)) << 16)+ (((int)(temp_data[REPORTID_21_LEN + 6 ] & 0xff)) << 8)+ (int)(temp_data[REPORTID_21_LEN + 7] & 0xff);reportID = 0x0321;DBG_FW("%s Report ID : 0x21\n" , __FUNCTION__);break;case 0x25:size = (((u16)(temp_data[REPORTID_25_LEN] & 0xff)) << 24)+ (((u16)(temp_data[REPORTID_25_LEN + 1] & 0xff)) << 16)+ (((u16)(temp_data[REPORTID_25_LEN + 2] & 0xff)) << 8)+ (u16)(temp_data[REPORTID_25_LEN + 3] & 0xff);timeout = (((int)(temp_data[REPORTID_25_LEN + 4] & 0xff)) << 24)+ (((int)(temp_data[REPORTID_25_LEN + 5] & 0xff)) << 16)+ (((int)(temp_data[REPORTID_25_LEN + 6 ] & 0xff)) << 8)+ (int)(temp_data[REPORTID_25_LEN + 7] & 0xff);reportID = 0x0325;DBG_FW("%s Report ID : 0x25\n" , __FUNCTION__);break;case 0x29:size = (((u16)(temp_data[REPORTID_29_LEN] & 0xff)) << 24)+ (((u16)(temp_data[REPORTID_29_LEN + 1] & 0xff)) << 16)+ (((u16)(temp_data[REPORTID_29_LEN + 2] & 0xff)) << 8)+ (u16)(temp_data[REPORTID_29_LEN + 3] & 0xff);timeout = (((int)(temp_data[REPORTID_29_LEN + 4] & 0xff)) << 24)+ (((int)(temp_data[REPORTID_29_LEN + 5] & 0xff)) << 16)+ (((int)(temp_data[REPORTID_29_LEN + 6 ] & 0xff)) << 8)+ (int)(temp_data[REPORTID_29_LEN + 7] & 0xff);reportID = 0x0329;DBG_FW("%s Report ID : 0x29\n" , __FUNCTION__);break;case 0x2d:size = (((u16)(temp_data[REPORTID_2D_LEN] & 0xff)) << 24)+ (((u16)(temp_data[REPORTID_2D_LEN + 1] & 0xff)) << 16)+ (((u16)(temp_data[REPORTID_2D_LEN + 2] & 0xff)) << 8)+ (u16)(temp_data[REPORTID_2D_LEN + 3] & 0xff);timeout = (((int)(temp_data[REPORTID_2D_LEN + 4] & 0xff)) << 24)+ (((int)(temp_data[REPORTID_2D_LEN + 5] & 0xff)) << 16)+ (((int)(temp_data[REPORTID_2D_LEN + 6 ] & 0xff)) << 8)+ (int)(temp_data[REPORTID_2D_LEN + 7] & 0xff);reportID = 0x032d;DBG_FW("%s Report ID : 0x2d\n" , __FUNCTION__);break;default:break;}
#elsesize = (((u16)(temp_data[64] & 0xff)) << 24) + (((u16)(temp_data[65] & 0xff)) << 16) + (((u16)(temp_data[66] & 0xff)) << 8) + (u16)(temp_data[67] & 0xff);timeout = (((int)(temp_data[68] & 0xff)) << 24) + (((int)(temp_data[69] & 0xff)) << 16) + (((int)(temp_data[70] & 0xff)) << 8) + (int)(temp_data[71] & 0xff);DBG_FW("%s Report ID : 0x09\n" , __FUNCTION__);
#endifDBG_FW("timeout = %d, size %d\n", timeout, size);kfree(temp_data);temp_data = NULL;#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)if (!access_ok(VERIFY_WRITE, buf, size)) {
#elseif (!access_ok(buf, size)) {
#endifprintk(KERN_INFO "cannot access user space memory\n");return -11;}rep_data = kzalloc(size, GFP_KERNEL);if (!rep_data) {printk(KERN_INFO "kzalloc rep_data fail\n");return -12;}if (copy_from_user(rep_data, (void*)buf, size)) {printk(KERN_INFO "copy_to_user fail(rep_data)\n");//free allocated datakfree(rep_data);rep_data = NULL;return -19;}#if IS_ENABLED(CONFIG_HID_SIS95XX_SIS98XX)rep_ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0x09, (USB_DIR_OUT|USB_TYPE_CLASS|USB_RECIP_INTERFACE), reportID, 0, rep_data, size, timeout);DBG_FW("%s: rep_data = ", __FUNCTION__);sis_dbg_dump_array(rep_data, 8);if (copy_to_user((void*)buf, rep_data, rep_ret)) {printk(KERN_INFO "copy_to_user fail(buf)\n");//free allocated datakfree(rep_data);rep_data = NULL;return -19;}
#elserep_ret = usb_interrupt_msg(dev, usbhid->urbout->pipe,rep_data, size, &actual_length, timeout);DBG_FW("%s: rep_data = ", __FUNCTION__);sis_dbg_dump_array(rep_data, size);if (rep_ret == 0) {if (copy_to_user((void*)buf, rep_data, actual_length)) {printk(KERN_INFO "copy_to_user fail(buf)\n");//free allocated datakfree(rep_data);rep_data = NULL;return -19;}}
#endif		DBG_FW("%s: rep_ret = %ld\n", __FUNCTION__, rep_ret);//free allocated datakfree(rep_data);rep_data = NULL;DBG_FW("End of sys_sis_HID_IO\n");return rep_ret;
}//for ioctl
static const struct file_operations sis_cdev_fops = {.owner	= THIS_MODULE,.read	= sis_cdev_read,.write	= sis_cdev_write,.open	= sis_cdev_open,.release= sis_cdev_release,
};//for ioctl
int sis_setup_chardev(struct hid_device *hdev)
{dev_t dev = MKDEV(sis_char_major, 0);int alloc_ret = 0;int cdev_err = 0;int input_err = 0;struct device *class_dev = NULL;void *ptr_err;printk("sis_setup_chardev.\n");hid_dev_backup = hdev;backup_urb = usb_alloc_urb(0, GFP_KERNEL); //0721testif (!backup_urb) {dev_err(&hdev->dev, "cannot allocate backup_urb\n");return -ENOMEM;}// dynamic allocate driver handle
#ifdef SIS_BRIDGE_ENABLEDalloc_ret = alloc_chrdev_region(&dev, 0, sis_char_devs_count, SIS_BRIDGE_DEVICE_NAME);
#elsealloc_ret = alloc_chrdev_region(&dev, 0, sis_char_devs_count, SIS_DEVICE_NAME);
#endif		if (alloc_ret)goto error;sis_char_major  = MAJOR(dev);cdev_init(&sis_char_cdev, &sis_cdev_fops);sis_char_cdev.owner = THIS_MODULE;cdev_err = cdev_add(&sis_char_cdev, MKDEV(sis_char_major, 0), sis_char_devs_count);if (cdev_err) goto error;#ifdef SIS_BRIDGE_ENABLEDprintk(KERN_INFO "%s driver(major %d) installed.\n", SIS_BRIDGE_DEVICE_NAME, sis_char_major);
#elseprintk(KERN_INFO "%s driver(major %d) installed.\n", SIS_DEVICE_NAME, sis_char_major);
#endif// register class
#ifdef SIS_BRIDGE_ENABLED
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)sis_char_class = class_create(THIS_MODULE, SIS_BRIDGE_DEVICE_NAME);
#elsesis_char_class = class_create(SIS_BRIDGE_DEVICE_NAME);
#endif //LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)
#else
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)sis_char_class = class_create(THIS_MODULE, SIS_DEVICE_NAME);
#elsesis_char_class = class_create(SIS_DEVICE_NAME);
#endif //LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)
#endif //SIS_BRIDGE_ENABLEDif (IS_ERR(ptr_err = sis_char_class))goto err2;#ifdef SIS_BRIDGE_ENABLEDclass_dev = device_create(sis_char_class, NULL, MKDEV(sis_char_major, 0), NULL, SIS_BRIDGE_DEVICE_NAME);
#elseclass_dev = device_create(sis_char_class, NULL, MKDEV(sis_char_major, 0), NULL, SIS_DEVICE_NAME);
#endifif (IS_ERR(ptr_err = class_dev)) goto err;return 0;
error:if (cdev_err == 0)cdev_del(&sis_char_cdev);if (alloc_ret == 0)unregister_chrdev_region(MKDEV(sis_char_major, 0), sis_char_devs_count);if (input_err != 0)printk("sis_ts_bak error!\n");
err:device_destroy(sis_char_class, MKDEV(sis_char_major, 0));
err2:class_destroy(sis_char_class);return -1;
}
EXPORT_SYMBOL(sis_setup_chardev);void sis_deinit_chardev(struct hid_device *hdev)
{//for ioctldev_t dev;printk(KERN_INFO "sis_deinit\n");dev = MKDEV(sis_char_major, 0);cdev_del(&sis_char_cdev);unregister_chrdev_region(dev, sis_char_devs_count);device_destroy(sis_char_class, MKDEV(sis_char_major, 0));class_destroy(sis_char_class);usb_kill_urb(backup_urb);usb_free_urb(backup_urb);backup_urb = NULL;hid_dev_backup = NULL;}
EXPORT_SYMBOL(sis_deinit_chardev);MODULE_DESCRIPTION("SiS Touchscreen Control Driver");
MODULE_LICENSE("GPL");

hid-sis_ctrl.h :包含了与 HID 设备通信和控制相关的宏定义、结构体定义、函数声明等内容。这些内容通常用于描述 HID 设备的特性、命令格式、数据结构等,以便在驱动程序中使用。

#ifndef __HID_SIS_CTRL_H__
#define __HID_SIS_CTRL_H__#include <linux/version.h>	//LINUX_VERSION_CODE & KERNEL_VERSION#if LINUX_VERSION_CODE < KERNEL_VERSION(4,12,0)
#include <asm/uaccess.h>	//copy_from_user() & copy_to_user()
#else
#include <linux/uaccess.h>	//copy_from_user() & copy_to_user()
#endif/* ID-table */
#define USB_VENDOR_ID_SIS_TOUCH	0x0457
#define USB_DEVICE_ID_SIS_TOUCH 0x1905/* Device node name */
#define HID_SIS95XX			// ON/OFF: SiS hydra(6596)/SiS aegis(817)
//#define DEBUG_HID_SIS_UPDATE_FW	// ON/OFF
//#define SIS_BRIDGE_ENABLED		// ON/OFF#if IS_ENABLED(CONFIG_HID_SIS95XX_SIS98XX)			//6596
#define SIS_DEVICE_NAME "sis_hydra_hid_touch_device"
#define SIS_BRIDGE_DEVICE_NAME "sis_hydra_hid_bridge_touch_device"
#else					//817
#define SIS_DEVICE_NAME "sis_aegis_hid_touch_device"
#define SIS_BRIDGE_DEVICE_NAME "sis_aegis_hid_bridge_touch_device"
#endif/* Report id length */
#define	REPORTID_21_LEN	64
#define	REPORTID_25_LEN	320
#define	REPORTID_29_LEN	576
#define	REPORTID_2D_LEN	832#define CTRL 0
#define ENDP_01 1
#define ENDP_02 2
#define DIR_IN 0x1int sis_cdev_open(struct inode *inode, struct file *filp);
int sis_cdev_release(struct inode *inode, struct file *filp);
ssize_t sis_cdev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos);
ssize_t sis_cdev_write( struct file *file, const char __user *buf, size_t count, loff_t *f_pos );
int sis_setup_chardev(struct hid_device *hdev);
void sis_deinit_chardev(struct hid_device *hdev);#endif	// __HID_SIS_CTRL_H__

2. 修改专用驱动程序列表

kernel version is >= 4.16

a.hid-multitouch.c修改

引用文件,类定义,启动功能,完成功能,添加设备列表

diff --git a/kernel/drivers/hid/hid-multitouch.c b/kernel/drivers/hid/hid-multitouch.c
index 19dfd8acd0..66399569ce 100644
--- a/kernel/drivers/hid/hid-multitouch.c
+++ b/kernel/drivers/hid/hid-multitouch.c
@@ -43,7 +43,9 @@
#include <linux/jiffies.h>
#include <linux/string.h>
#include <linux/timer.h>
-
+/* SiSdrv Start */
+#include "hid-sis_ctrl.h"
+/* SiSdrv End */
MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>");
@@ -207,6 +209,9 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
#define MT_CLS_VTL                0x0110
#define MT_CLS_GOOGLE                0x0111
#define MT_CLS_RAZER_BLADE_STEALTH        0x0112
+/* SiSdrv Start */
+#define MT_CLS_SIS              0x0457
+/* SiSdrv End */
#define MT_DEFAULT_MAXCONTACT    10
#define MT_MAX_MAXCONTACT    250
@@ -357,6 +362,12 @@ static const struct mt_class mt_classes[] = {MT_QUIRK_CONTACT_CNT_ACCURATE |MT_QUIRK_WIN8_PTP_BUTTONS,},
+    /* SiSdrv Start */
+    { .name = MT_CLS_SIS,
+        .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
+            MT_QUIRK_CONTACT_CNT_ACCURATE
+    },
+    /* SiSdrv End */{ }
};
@@ -1716,6 +1727,18 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID)mt_fix_const_fields(hdev, HID_DG_CONTACTID);
+    /* SiSdrv Start */
+    if (hdev->vendor == USB_VENDOR_ID_SIS_TOUCH) {
+        hdev->quirks |= HID_QUIRK_NOGET;
+        printk(KERN_INFO "sis:sis-probe: quirk = %x\n", hdev->quirks);
+    #ifdef CONFIG_HID_SIS_CTRL
+        ret = sis_setup_chardev(hdev);
+        if (ret)
+            printk( KERN_INFO "sis_setup_chardev fail\n");
+    #endif  //CONFIG_HID_SIS_CTRL
+    }
+    /* SiSdrv End */
+ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);if (ret)return ret;
@@ -1757,6 +1780,13 @@ static void mt_remove(struct hid_device *hdev)del_timer_sync(&td->release_timer);sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group);
+
+    /* SiSdrv Start */
+    if (hdev->vendor == USB_VENDOR_ID_SIS_TOUCH) {
+        sis_deinit_chardev(hdev);
+    }
+    /* SiSdrv End */
+hid_hw_stop(hdev);
}
@@ -2103,6 +2133,12 @@ static const struct hid_device_id mt_devices[] = {HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_GOOGLE,USB_DEVICE_ID_GOOGLE_TOUCH_ROSE) },
+    /* SiSdrv Start */
+    { .driver_data = MT_CLS_SIS,
+        HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_SIS_TOUCH,
+            HID_ANY_ID) },
+    /* SiSdrv End */
+/* Generic MT device */{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) },

b.hid-quirks.c修改

将usb触摸vid添加特殊设备列表中

diff --git a/kernel/drivers/hid/hid-quirks.c b/kernel/drivers/hid/hid-quirks.c
index b9529bed4d..c913bfd889 100644
--- a/kernel/drivers/hid/hid-quirks.c
+++ b/kernel/drivers/hid/hid-quirks.c
@@ -720,6 +720,11 @@ static const struct hid_device_id hid_have_special_driver[] = {
#if IS_ENABLED(CONFIG_HID_ZYDACRON){ HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
#endif
+/* SiSdrv Start */
+#if IS_ENABLED(CONFIG_HID_SIS92XX) || IS_ENABLED(CONFIG_HID_SIS95XX_SIS98XX)
+    { HID_USB_DEVICE(0x0457, HID_ANY_ID) },
+#endif
+/* SiSdrv End */{ }
};

3. 移植hid_sis驱动

a. 将驱动(hid-sis_ctrl.c,hid-sis_ctrl.h)拷贝到下面的文件夹:

kernel/drivers/hid/

b. 在 Makefile 中添加hid-sis_ctrl设备

kernel/drivers/hid/Makefile:#/  SiSdrv Start    /
obj-$(CONFIG_HID_SIS_CTRL)  += hid-sis_ctrl.o
#/  SiSdrv End  /

c. 在 Kconfig 中添加hid-sis_ctrl

kernel/drivers/hid/Kconfig:#/  SiSdrv Start    /   
config HID_SIS_CTRLtristate "SiS Touch Device Controller"depends on HID_MULTITOUCHdefault yhelpSupport for SiS Touch devices update FW.menu "SiS touchscreen series"
choicedepends on USB_HIDdepends on HID_SIS_CTRLprompt "SiS controller select"config HID_SIS95XX_SIS98XXdepends on HID_SIS_CTRLtristate "SiS 95xx and 98xx series Touch Device"helpSupport for SiS Touch devices that are fully compliant with HID standard.config HID_SIS92XXdepends on HID_SIS_CTRLtristate "SiS 92xx series Touch Device"helpSupport for SiS Touch devices that are fully compliant with HID standard.endchoiceconfig DEBUG_HID_SIS_UPDATE_FWbool "SiS Touch device update firmware support debug message enable"depends on HID_SIS_CTRLdefault nhelpSay Y here if you want to enable debug message offirmware updating for SiS Touchdevices.endmenu
#/  SiSdrv End  /

d. 内核中加载驱动

kernel/arch/arm64/configs/rockchip_defconfig:CONFIG_HID_SIS95XX_SIS98XX=m

三,系统配置

1.授予sis节点权限

diff --git a/system/core/rootdir/ueventd.rc b/system/core/rootdir/ueventd.rc
index 451f5adf33..28c3d83eb7 100644
--- a/system/core/rootdir/ueventd.rc
+++ b/system/core/rootdir/ueventd.rc
@@ -40,6 +40,10 @@ subsystem sound
/dev/pmsg0                0222   root       log
+#sis device SiS95xx
+/dev/sis_hydra_hid_touch_device 0666 root root
+/dev/sis_hydra_hid_bridge_touch_device 0666 root root
+
# kms driver for drm based gpu
/dev/dri/*                0666   root       graphics

2. idc文件拷贝到 系统system/usr/idc/目录

rc文件中添加:

PRODUCT_COPY_FILES += \device/rockchip/rk3399/Vendor_0457_Product_0819.idc:system/usr/idc/Vendor_0457_Product_0819.idc
Vendor_0457_Product_0819.idc:# Basic Parameters
touch.deviceType = touchScreen
touch.orientationAware = 1
device.internal = 1

四,调试

1.dmesg日志

dmesg | grep sis //检查sis驱动程序加载

在这里插入图片描述

2.设备节点

ls -l /dev/sis*

在这里插入图片描述

cat /proc/bus/input/devices

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/280644.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ReaLTaiizor开源.NET winform控件库学习使用

一、ReaLTaiizor项目介绍 1.1 介绍及地址 基于MIT license开源、免费、美观的.NET WinForm UI控件库&#xff1a;ReaLTaiizor ReaLTaiizor是一个开源免费的.NET WinForms控件库&#xff0c;它提供了广泛的组件和丰富的主题选项&#xff08;用户友好、注重设计&#xff09;&am…

单片机-- 数电(3)

编码器与译码器 译码 &#xff1a;将二进制代码转化为其他进制的代码 编码 &#xff1a;就是将其他代码转换为二进制码 编码器的类型 1二进制编码器 用n位二进制数码对2的n次方个输入信号进行编码的电路 2二-十进制编码器 将0到9十个十进制数转化为二进制代码的电路 2…

Uibot6.0 (RPA财务机器人师资培训第1天 )RPA+AI、RPA基础语法

训练网站&#xff1a;泓江科技 (lessonplan.cn)https://laiye.lessonplan.cn/list/ec0f5080-e1de-11ee-a1d8-3f479df4d981(本博客中会有部分课程ppt截屏,如有侵权请及请及时与小北我取得联系~&#xff09; 紧接着小北之前的几篇博客&#xff0c;友友们我们即将开展新课的学习~…

绝地求生:七周年活动来袭,小黑盒联名限时返场

就在2024.3.20号下午18点&#xff0c;小黑盒绝地求生板块上线最新活动&#xff0c;活动方法和以往一样采用积分抽奖的方式&#xff0c;通过每日签到&#xff0c;完成任务即可获得相应积分&#xff0c;抽奖需消耗10积分&#xff0c;第一天可以抽8次&#xff0c;后面每一天可以抽…

【Python + Django】Django模板语法 + 请求和响应

前言&#xff1a; 现在现在&#xff0c;我们要开始将变量的值展现在页面上面啦&#xff01; 要是只会显示静态页面&#xff0c;我们的页面也太难看和死板了&#xff0c; 并且数据库的数据也没法展现在页面上。 但是呢&#xff0c;模板语法学习之后就可以啦&#xff01;&…

Midjourney角色一致功能解读

在无数AI绘画创作者的胡呼声中&#xff0c;Midjourney终于推出了“角色一致性”功能&#xff0c;该功能可在新图像中一致地重新创建角色。AI绘画中的主要障碍终被打破。 这是因为大多数AI图像生成器都依赖于“扩散模型”&#xff0c;这些工具类似于或基于Stability AI的Stable…

IDEA中快速配置Git

Git介绍&#xff1a; Git下载 idea中配置Git

如何使用人工智能打造超用户预期的个性化购物体验

回看我的营销职业生涯&#xff0c;我见证了数字时代如何重塑客户期望。从一刀切的方法过渡到创造高度个性化的购物体验已成为企业的关键。在这个客户期望不断变化的新时代&#xff0c;创造个性化的购物体验不再是奢侈品&#xff0c;而是企业的必需品。人工智能 &#xff08;AI&…

面试题 之 react

1.说说对react的理解 1️⃣是什么 React是用于构建用户界面的 JavaScript 库,遵循组件设计模式、声明式编程范式和函数式编程概念&#xff0c;更高效使用虚拟 DOM 来有效地操作 DOM &#xff0c;遵循从高阶组件到低阶组件的单向数据流。 react 类组件使用一个名为 render() 的方…

【linux】环境基础|开发工具|gcc|yum|vim|gdb|make|git

目录 ​编辑 Linux 软件包管理器 yum 软件包: 操作&#xff1a; 拓展&#xff1a;lrzsz简介 Linux开发工具 Linux编辑器-vim使用 vim 的基本概念 命令模式 插入模式 底行模式 vim 命令模式的操作指令 vim 底行模式的操作命令 Linux编译器-gcc/g使用 功能 格…

SQLiteC/C++接口详细介绍sqlite3_stmt类(二)

返回目录&#xff1a;SQLite—免费开源数据库系列文章目录 上一篇&#xff1a;SQLiteC/C接口详细介绍sqlite3_stmt类简介 下一篇&#xff1a;SQLiteC/C接口详细介绍sqlite3_stmt类&#xff08;三&#xff09; sqlite3_reset() 功能&#xff1a;重置一个准备好执行的SQL语…

Mysql——基础命令集合

目录 前期准备 先登录数据库 一、管理数据库 1.数据表结构解析 2.常用数据类型 3.适用所有类型的修饰符 4.使用数值型的修饰符 二、SQL语句 1.SQL语言分类 三、Mysql——Create,Show,Describe,Drop 1.创建数据库 2.查看数据库 3.切换数据库 4.创建数据表 5.查看…

Flink RocksDB状态后端优化总结

截至当前&#xff0c;Flink 作业的状态后端仍然只有 Memory、FileSystem 和 RocksDB 三种可选&#xff0c;且 RocksDB 是状态数据量较大&#xff08;GB 到 TB 级别&#xff09;时的唯一选择。RocksDB 的性能发挥非常仰赖调优&#xff0c;如果全部采用默认配置&#xff0c;读写性…

风速预测(八)VMD-CNN-Transformer预测模型

往期精彩内容&#xff1a; 时序预测&#xff1a;LSTM、ARIMA、Holt-Winters、SARIMA模型的分析与比较-CSDN博客 风速预测&#xff08;一&#xff09;数据集介绍和预处理-CSDN博客 风速预测&#xff08;二&#xff09;基于Pytorch的EMD-LSTM模型-CSDN博客 风速预测&#xff…

Sora后时代文生视频的探索

一、写在前面 按常理&#xff0c;这里应该长篇大论地介绍一下Sora发布对各行业各方面产生的影响。不过&#xff0c;这类文章已经很多了&#xff0c;我们今天主要聊聊那些已经成熟的解决方案、那些已经可以“信手拈来”的成果&#xff0c;并以此为基础&#xff0c;看看Sora发布…

GB28181 —— 5、C++编写GB28181设备端,完成将USB摄像头视频实时转发至GB28181服务并可播放(附源码)

被测试的USB摄像头 效果 源码说明 主要功能模拟设备端,完成注册、注销、心跳等,同时当服务端下发指令播放视频时 设备端实时读取USB摄像头视频并通过OpenCV处理后实时转ps格式后封包rtp进行推送给服务端播放。 源码 /****@remark: pes头的封装,里面的具体数据的填写已经占…

远程传输大文件的软件 远程文件传输

在数字化时代&#xff0c;随着数据量的急剧增长&#xff0c;远程传输大文件变得越来越重要。无论是企业间的合作&#xff0c;还是个人的日常需求&#xff0c;高效、稳定、安全的远程文件传输都是关键。本文将介绍远程传输大文件的相关软件及其特点&#xff0c;帮助读者选择最适…

应急响应-Web2

应急响应-Web2 1.攻击者的IP地址&#xff08;两个&#xff09;&#xff1f; 192.168.126.135 192.168.126.129 通过phpstudy查看日志&#xff0c;发现192.168.126.135这个IP一直在404访问 &#xff0c; 并且在日志的最后几条一直在访问system.php &#xff0c;从这可以推断 …

Simulink|局部遮荫下光伏组件多峰值PSO-MPPT控制

目录 主要内容 1.光伏电池工程数学模型的输出特性程序 2.普通扰动观察法进行MPPT 3.基于粒子群寻优的多峰输出特性 4.PSO_MPPT仿真模型 下载链接 主要内容 在实际的光伏发电系统中&#xff0c;由于环境多变等因素的影响&#xff0c;当局部出现被遮挡情况时光伏阵列…

Beamer模板——基于LaTeX制作学术PPT

Beamer模板——基于LaTeX制作学术PPT 介绍Beamer的基本使用安装和编译用于学术汇报的模板项目代码模板效果图 Beamer的高级特性动态效果分栏布局定理环境 介绍 在学术领域&#xff0c;演示文稿是展示和讨论研究成果的重要方式。传统的PowerPoint虽然方便&#xff0c;但在处理复…