mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 12:33:27 +08:00
drivers/virtio: add virtio input driver
Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
5572552024
commit
72587c6e79
@@ -33,6 +33,11 @@ config DRIVERS_VIRTIO_GPU
|
||||
depends on VIDEO_FB
|
||||
select FB_UPDATE
|
||||
|
||||
config DRIVERS_VIRTIO_INPUT
|
||||
bool "Virtio input support"
|
||||
default n
|
||||
depends on INPUT
|
||||
|
||||
config DRIVERS_VIRTIO_NET
|
||||
bool "Virtio network support"
|
||||
depends on NETDEVICES
|
||||
|
||||
@@ -36,6 +36,10 @@ ifeq ($(CONFIG_DRIVERS_VIRTIO_GPU),y)
|
||||
CSRCS += virtio-gpu.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DRIVERS_VIRTIO_INPUT),y)
|
||||
CSRCS += virtio-input.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DRIVERS_VIRTIO_NET),y)
|
||||
CSRCS += virtio-net.c
|
||||
endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,112 @@
|
||||
/****************************************************************************
|
||||
* drivers/virtio/virtio-input.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __DRIVERS_VIRTIO_VIRTIO_INPUT_H
|
||||
#define __DRIVERS_VIRTIO_VIRTIO_INPUT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef CONFIG_DRIVERS_VIRTIO_INPUT
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define VIRTIO_INPUT_CFG_UNSET 0x00
|
||||
#define VIRTIO_INPUT_CFG_ID_NAME 0x01
|
||||
#define VIRTIO_INPUT_CFG_ID_SERIAL 0x02
|
||||
#define VIRTIO_INPUT_CFG_ID_DEVIDS 0x03
|
||||
#define VIRTIO_INPUT_CFG_PROP_BITS 0x10
|
||||
#define VIRTIO_INPUT_CFG_EV_BITS 0x11
|
||||
#define VIRTIO_INPUT_CFG_ABS_INFO 0x12
|
||||
|
||||
#define VIRTIO_INPUT_CHUNK_SIZE 128 /* 128 bytes per chunk */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
begin_packed_struct struct virtio_input_absinfo
|
||||
{
|
||||
uint32_t min;
|
||||
uint32_t max;
|
||||
uint32_t fuzz;
|
||||
uint32_t flat;
|
||||
uint32_t res;
|
||||
} end_packed_struct;
|
||||
|
||||
begin_packed_struct struct virtio_input_devids
|
||||
{
|
||||
uint16_t bustype;
|
||||
uint16_t vendor;
|
||||
uint16_t product;
|
||||
uint16_t version;
|
||||
} end_packed_struct;
|
||||
|
||||
begin_packed_struct struct virtio_input_config
|
||||
{
|
||||
uint8_t select;
|
||||
uint8_t subsel;
|
||||
uint8_t size;
|
||||
uint8_t reserved[5];
|
||||
union
|
||||
{
|
||||
char string[VIRTIO_INPUT_CHUNK_SIZE];
|
||||
uint8_t bitmap[VIRTIO_INPUT_CHUNK_SIZE];
|
||||
struct virtio_input_absinfo abs;
|
||||
struct virtio_input_devids ids;
|
||||
} u;
|
||||
} end_packed_struct;
|
||||
|
||||
begin_packed_struct struct virtio_input_event
|
||||
{
|
||||
uint16_t type;
|
||||
uint16_t code;
|
||||
uint32_t value;
|
||||
} end_packed_struct;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
int virtio_register_input_driver(void);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_DRIVERS_VIRTIO_INPUT */
|
||||
|
||||
#endif /* __DRIVERS_VIRTIO_VIRTIO_INPUT_H */
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "virtio-blk.h"
|
||||
#include "virtio-gpu.h"
|
||||
#include "virtio-input.h"
|
||||
#include "virtio-net.h"
|
||||
#include "virtio-rng.h"
|
||||
#include "virtio-serial.h"
|
||||
@@ -135,6 +136,14 @@ void virtio_register_drivers(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DRIVERS_VIRTIO_INPUT
|
||||
ret = virtio_register_input_driver();
|
||||
if (ret < 0)
|
||||
{
|
||||
vrterr("virtio_register_input_driver failed, ret=%d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DRIVERS_VIRTIO_NET
|
||||
ret = virtio_register_net_driver();
|
||||
if (ret < 0)
|
||||
|
||||
Reference in New Issue
Block a user