drivers/input/touchscreen/inexio.c

Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/inexio.c

File Facts

System
Linux kernel
Corpus path
drivers/input/touchscreen/inexio.c
Extension
.c
Size
4457 bytes
Lines
187
Domain
Driver Families
Bucket
drivers/input
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct inexio {
	struct input_dev *dev;
	struct serio *serio;
	int idx;
	unsigned char data[INEXIO_MAX_LENGTH];
	char phys[32];
};

static void inexio_process_data(struct inexio *pinexio)
{
	struct input_dev *dev = pinexio->dev;

	if (INEXIO_FORMAT_LENGTH == ++pinexio->idx) {
		input_report_abs(dev, ABS_X, INEXIO_GET_XC(pinexio->data));
		input_report_abs(dev, ABS_Y, INEXIO_GET_YC(pinexio->data));
		input_report_key(dev, BTN_TOUCH, INEXIO_GET_TOUCHED(pinexio->data));
		input_sync(dev);

		pinexio->idx = 0;
	}
}

static irqreturn_t inexio_interrupt(struct serio *serio,
		unsigned char data, unsigned int flags)
{
	struct inexio *pinexio = serio_get_drvdata(serio);

	pinexio->data[pinexio->idx] = data;

	if (INEXIO_RESPONSE_BEGIN_BYTE&pinexio->data[0])
		inexio_process_data(pinexio);
	else
		printk(KERN_DEBUG "inexio.c: unknown/unsynchronized data from device, byte %x\n",pinexio->data[0]);

	return IRQ_HANDLED;
}

/*
 * inexio_disconnect() is the opposite of inexio_connect()
 */

static void inexio_disconnect(struct serio *serio)
{
	struct inexio *pinexio = serio_get_drvdata(serio);

	input_get_device(pinexio->dev);
	input_unregister_device(pinexio->dev);
	serio_close(serio);
	serio_set_drvdata(serio, NULL);
	input_put_device(pinexio->dev);
	kfree(pinexio);
}

/*
 * inexio_connect() is the routine that is called when someone adds a
 * new serio device that supports iNexio protocol and registers it as
 * an input device. This is usually accomplished using inputattach.
 */

static int inexio_connect(struct serio *serio, struct serio_driver *drv)
{
	struct inexio *pinexio;
	struct input_dev *input_dev;
	int err;

	pinexio = kzalloc_obj(*pinexio);
	input_dev = input_allocate_device();
	if (!pinexio || !input_dev) {
		err = -ENOMEM;
		goto fail1;
	}

	pinexio->serio = serio;
	pinexio->dev = input_dev;
	scnprintf(pinexio->phys, sizeof(pinexio->phys), "%s/input0", serio->phys);

	input_dev->name = "iNexio Serial TouchScreen";
	input_dev->phys = pinexio->phys;
	input_dev->id.bustype = BUS_RS232;
	input_dev->id.vendor = SERIO_INEXIO;
	input_dev->id.product = 0;
	input_dev->id.version = 0x0001;
	input_dev->dev.parent = &serio->dev;
	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
	input_set_abs_params(pinexio->dev, ABS_X, INEXIO_MIN_XC, INEXIO_MAX_XC, 0, 0);
	input_set_abs_params(pinexio->dev, ABS_Y, INEXIO_MIN_YC, INEXIO_MAX_YC, 0, 0);

	serio_set_drvdata(serio, pinexio);

Annotation

Implementation Notes