forked from xuos/xiuos
Adjust directory structure
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
SRC_FILES += drv_touch.c dev_touch.c bus_touch.c
|
||||
|
||||
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file bus_touch.c
|
||||
* @brief register touch bus function using bus driver framework
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-04-24
|
||||
*/
|
||||
|
||||
#include <bus_touch.h>
|
||||
#include <dev_touch.h>
|
||||
|
||||
int TouchBusInit(struct TouchBus *touch_bus, const char *bus_name)
|
||||
{
|
||||
NULL_PARAM_CHECK(touch_bus);
|
||||
NULL_PARAM_CHECK(bus_name);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
|
||||
if (BUS_INSTALL != touch_bus->bus.bus_state) {
|
||||
strncpy(touch_bus->bus.bus_name, bus_name, NAME_NUM_MAX);
|
||||
|
||||
touch_bus->bus.bus_type = TYPE_TOUCH_BUS;
|
||||
touch_bus->bus.bus_state = BUS_INSTALL;
|
||||
touch_bus->bus.private_data = touch_bus->private_data;
|
||||
|
||||
ret = BusRegister(&touch_bus->bus);
|
||||
if (EOK != ret) {
|
||||
KPrintf("touchBusInit BusRegister error %u\n", ret);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
KPrintf("touchBusInit BusRegister bus has been register state%u\n", touch_bus->bus.bus_state);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TouchDriverInit(struct TouchDriver *touch_driver, const char *driver_name)
|
||||
{
|
||||
NULL_PARAM_CHECK(touch_driver);
|
||||
NULL_PARAM_CHECK(driver_name);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
|
||||
if (DRV_INSTALL != touch_driver->driver.driver_state) {
|
||||
touch_driver->driver.driver_type = TYPE_TOUCH_DRV;
|
||||
touch_driver->driver.driver_state = DRV_INSTALL;
|
||||
|
||||
strncpy(touch_driver->driver.drv_name, driver_name, NAME_NUM_MAX);
|
||||
|
||||
touch_driver->driver.configure =touch_driver->configure;
|
||||
|
||||
ret = TouchDriverRegister(&touch_driver->driver);
|
||||
if (EOK != ret) {
|
||||
KPrintf("TouchDriverInit DriverRegister error %u\n", ret);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
KPrintf("TouchDriverInit DriverRegister driver has been register state%u\n", touch_driver->driver.driver_state);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TouchReleaseBus(struct TouchBus *touch_bus)
|
||||
{
|
||||
NULL_PARAM_CHECK(touch_bus);
|
||||
|
||||
return BusRelease(&touch_bus->bus);
|
||||
}
|
||||
|
||||
int TouchDriverAttachToBus(const char *drv_name, const char *bus_name)
|
||||
{
|
||||
NULL_PARAM_CHECK(drv_name);
|
||||
NULL_PARAM_CHECK(bus_name);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
|
||||
struct Bus *bus;
|
||||
struct Driver *driver;
|
||||
|
||||
bus = BusFind(bus_name);
|
||||
if (NONE == bus) {
|
||||
KPrintf("TouchDriverAttachToBus find touch bus error!name %s\n", bus_name);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (TYPE_TOUCH_BUS == bus->bus_type) {
|
||||
driver = TouchDriverFind(drv_name, TYPE_TOUCH_DRV);
|
||||
if (NONE == driver) {
|
||||
KPrintf("TouchDriverAttachToBus find touch driver error!name %s\n", drv_name);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (TYPE_TOUCH_DRV == driver->driver_type) {
|
||||
ret = DriverRegisterToBus(bus, driver);
|
||||
if (EOK != ret) {
|
||||
KPrintf("TouchDriverAttachToBus DriverRegisterToBus error %u\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file dev_touch.c
|
||||
* @brief register touch dev function using bus driver framework
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-04-24
|
||||
*/
|
||||
|
||||
#include <bus_touch.h>
|
||||
#include <dev_touch.h>
|
||||
|
||||
static DoubleLinklistType touchdev_linklist;
|
||||
|
||||
/*Create the touch device linklist*/
|
||||
static void TouchDeviceLinkInit()
|
||||
{
|
||||
InitDoubleLinkList(&touchdev_linklist);
|
||||
}
|
||||
|
||||
HardwareDevType TouchDeviceFind(const char *dev_name, enum DevType dev_type)
|
||||
{
|
||||
NULL_PARAM_CHECK(dev_name);
|
||||
|
||||
struct HardwareDev *device = NONE;
|
||||
|
||||
DoubleLinklistType *node = NONE;
|
||||
DoubleLinklistType *head = &touchdev_linklist;
|
||||
|
||||
for (node = head->node_next; node != head; node = node->node_next){
|
||||
device = SYS_DOUBLE_LINKLIST_ENTRY(node, struct HardwareDev, dev_link);
|
||||
if ((!strcmp(device->dev_name, dev_name)) && (dev_type == device->dev_type)) {
|
||||
return device;
|
||||
}
|
||||
}
|
||||
|
||||
KPrintf("TouchDeviceFind cannot find the %s device.return NULL\n", dev_name);
|
||||
return NONE;
|
||||
}
|
||||
|
||||
int TouchDeviceRegister(struct TouchHardwareDevice *touch_device, void *touch_param, const char *device_name)
|
||||
{
|
||||
NULL_PARAM_CHECK(touch_device);
|
||||
NULL_PARAM_CHECK(device_name);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
|
||||
static x_bool dev_link_flag = RET_FALSE;
|
||||
|
||||
if (!dev_link_flag) {
|
||||
TouchDeviceLinkInit();
|
||||
dev_link_flag = RET_TRUE;
|
||||
}
|
||||
|
||||
if (DEV_INSTALL != touch_device->haldev.dev_state) {
|
||||
strncpy(touch_device->haldev.dev_name, device_name, NAME_NUM_MAX);
|
||||
touch_device->haldev.dev_type = TYPE_TOUCH_DEV;
|
||||
touch_device->haldev.dev_state = DEV_INSTALL;
|
||||
|
||||
touch_device->haldev.dev_done = (struct HalDevDone *)touch_device->dev_done;
|
||||
|
||||
touch_device->haldev.private_data = touch_param;
|
||||
|
||||
DoubleLinkListInsertNodeAfter(&touchdev_linklist, &(touch_device->haldev.dev_link));
|
||||
} else {
|
||||
KPrintf("TouchDeviceRegister device has been register state%u\n", touch_device->haldev.dev_state);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TouchDeviceAttachToBus(const char *dev_name, const char *bus_name)
|
||||
{
|
||||
NULL_PARAM_CHECK(dev_name);
|
||||
NULL_PARAM_CHECK(bus_name);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
|
||||
struct Bus *bus;
|
||||
struct HardwareDev *device;
|
||||
|
||||
bus = BusFind(bus_name);
|
||||
if (NONE == bus) {
|
||||
KPrintf("TouchDeviceAttachToBus find touch bus error!name %s\n", bus_name);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (TYPE_TOUCH_BUS == bus->bus_type) {
|
||||
device = TouchDeviceFind(dev_name, TYPE_TOUCH_DEV);
|
||||
if (NONE == device) {
|
||||
KPrintf("TouchDeviceAttachToBus find TOUCH device error!name %s\n", dev_name);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
if (TYPE_TOUCH_DEV == device->dev_type) {
|
||||
ret = DeviceRegisterToBus(bus, device);
|
||||
if (EOK != ret) {
|
||||
KPrintf("TouchDeviceAttachToBus DeviceRegisterToBus error %u\n", ret);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EOK;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2020 AIIT XUOS Lab
|
||||
* XiUOS is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file drv_touch.c
|
||||
* @brief register touch drv function using bus driver framework
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-04-24
|
||||
*/
|
||||
|
||||
#include <bus_touch.h>
|
||||
#include <dev_touch.h>
|
||||
|
||||
static DoubleLinklistType touchdrv_linklist;
|
||||
|
||||
/*Create the driver linklist*/
|
||||
static void TouchDrvLinkInit()
|
||||
{
|
||||
InitDoubleLinkList(&touchdrv_linklist);
|
||||
}
|
||||
|
||||
DriverType TouchDriverFind(const char *drv_name, enum DriverType drv_type)
|
||||
{
|
||||
NULL_PARAM_CHECK(drv_name);
|
||||
|
||||
struct Driver *driver = NONE;
|
||||
|
||||
DoubleLinklistType *node = NONE;
|
||||
DoubleLinklistType *head = &touchdrv_linklist;
|
||||
|
||||
for (node = head->node_next; node != head; node = node->node_next) {
|
||||
driver = SYS_DOUBLE_LINKLIST_ENTRY(node, struct Driver, driver_link);
|
||||
if ((!strcmp(driver->drv_name, drv_name)) && (drv_type == driver->driver_type)) {
|
||||
return driver;
|
||||
}
|
||||
}
|
||||
|
||||
KPrintf("TouchDriverFind cannot find the %s driver.return NULL\n", drv_name);
|
||||
return NONE;
|
||||
}
|
||||
|
||||
int TouchDriverRegister(struct Driver *driver)
|
||||
{
|
||||
NULL_PARAM_CHECK(driver);
|
||||
|
||||
x_err_t ret = EOK;
|
||||
static x_bool driver_link_flag = RET_FALSE;
|
||||
|
||||
if (!driver_link_flag) {
|
||||
TouchDrvLinkInit();
|
||||
driver_link_flag = RET_TRUE;
|
||||
}
|
||||
|
||||
DoubleLinkListInsertNodeAfter(&touchdrv_linklist, &(driver->driver_link));
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user