1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00
Files
u-boot-megous/drivers/input/touchpanel-uclass.c
Ondrej Jirman 88e72e2d24 input: Implemented touchpanel uclass for touchpanel devices
Touchapnel devices are useful in u-boot for implementation of boot
menu user interfaces on tablets and other touch based devices.

This uclass implements start, stop and get_touches interface methods.

Signed-off-by: Ondrej Jirman <megous@megous.com>
2024-10-08 15:41:09 +02:00

67 lines
1.4 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 2018 Ondrej Jirman <megous@megous.com>
*/
#include <errno.h>
#include <dm.h>
#include <dm/uclass-internal.h>
#include <touchpanel.h>
int touchpanel_start(struct udevice *dev)
{
const struct touchpanel_ops *ops = touchpanel_get_ops(dev);
if (!ops || !ops->start)
return -ENOSYS;
return ops->start(dev);
}
int touchpanel_stop(struct udevice *dev)
{
const struct touchpanel_ops *ops = touchpanel_get_ops(dev);
if (!ops || !ops->stop)
return -ENOSYS;
return ops->stop(dev);
}
int touchpanel_get_touches(struct udevice *dev,
struct touchpanel_touch* touches, int max_touches)
{
const struct touchpanel_ops *ops = touchpanel_get_ops(dev);
if (!ops || !ops->get_touches)
return -ENOSYS;
return ops->get_touches(dev, touches, max_touches);
}
static int touchpanel_pre_probe(struct udevice *dev)
{
struct touchpanel_priv *uc_priv;
uc_priv = dev_get_uclass_priv(dev);
if (!uc_priv)
return -ENXIO;
uc_priv->size_x = dev_read_u32_default(dev, "touchscreen-size-x",
-ENODATA);
uc_priv->size_y = dev_read_u32_default(dev, "touchscreen-size-y",
-ENODATA);
if (uc_priv->size_x == -ENODATA || uc_priv->size_y == -ENODATA)
uc_priv->size_x = uc_priv->size_y = -ENODATA;
return 0;
}
UCLASS_DRIVER(touchpanel) = {
.id = UCLASS_TOUCHPANEL,
.name = "touchpanel",
.pre_probe = touchpanel_pre_probe,
.per_device_auto = sizeof(struct touchpanel_priv),
};