drivers/input/touchscreen/mainstone-wm97xx.c

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

File Facts

System
Linux kernel
Corpus path
drivers/input/touchscreen/mainstone-wm97xx.c
Extension
.c
Size
6944 bytes
Lines
275
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 continuous {
	u16 id;    /* codec id */
	u8 code;   /* continuous code */
	u8 reads;  /* number of coord reads per read cycle */
	u32 speed; /* number of coords per second */
};

#define WM_READS(sp) ((sp / HZ) + 1)

static const struct continuous cinfo[] = {
	{ WM9705_ID2, 0, WM_READS(94),  94  },
	{ WM9705_ID2, 1, WM_READS(188), 188 },
	{ WM9705_ID2, 2, WM_READS(375), 375 },
	{ WM9705_ID2, 3, WM_READS(750), 750 },
	{ WM9712_ID2, 0, WM_READS(94),  94  },
	{ WM9712_ID2, 1, WM_READS(188), 188 },
	{ WM9712_ID2, 2, WM_READS(375), 375 },
	{ WM9712_ID2, 3, WM_READS(750), 750 },
	{ WM9713_ID2, 0, WM_READS(94),  94  },
	{ WM9713_ID2, 1, WM_READS(120), 120 },
	{ WM9713_ID2, 2, WM_READS(154), 154 },
	{ WM9713_ID2, 3, WM_READS(188), 188 },
};

/* continuous speed index */
static int sp_idx;
static struct gpio_desc *gpiod_irq;

/*
 * Pen sampling frequency (Hz) in continuous mode.
 */
static int cont_rate = 200;
module_param(cont_rate, int, 0);
MODULE_PARM_DESC(cont_rate, "Sampling rate in continuous mode (Hz)");

/*
 * Pen down detection.
 *
 * This driver can either poll or use an interrupt to indicate a pen down
 * event. If the irq request fails then it will fall back to polling mode.
 */
static int pen_int;
module_param(pen_int, int, 0);
MODULE_PARM_DESC(pen_int, "Pen down detection (1 = interrupt, 0 = polling)");

/*
 * Pressure readback.
 *
 * Set to 1 to read back pen down pressure
 */
static int pressure;
module_param(pressure, int, 0);
MODULE_PARM_DESC(pressure, "Pressure readback (1 = pressure, 0 = no pressure)");

/*
 * AC97 touch data slot.
 *
 * Touch screen readback data ac97 slot
 */
static int ac97_touch_slot = 5;
module_param(ac97_touch_slot, int, 0);
MODULE_PARM_DESC(ac97_touch_slot, "Touch screen data slot AC97 number");


/* flush AC97 slot 5 FIFO on pxa machines */
static void wm97xx_acc_pen_up(struct wm97xx *wm)
{
	unsigned int count;

	msleep(1);

	if (cpu_is_pxa27x()) {
		while (pxa2xx_ac97_read_misr() & (1 << 2))
			pxa2xx_ac97_read_modr();
	} else if (cpu_is_pxa3xx()) {
		for (count = 0; count < 16; count++)
			pxa2xx_ac97_read_modr();
	}
}

static int wm97xx_acc_pen_down(struct wm97xx *wm)
{
	u16 x, y, p = 0x100 | WM97XX_ADCSEL_PRES;
	int reads = 0;
	static u16 last, tries;

	/* When the AC97 queue has been drained we need to allow time
	 * to buffer up samples otherwise we end up spinning polling
	 * for samples.  The controller can't have a suitably low
	 * threshold set to use the notifications it gives.

Annotation

Implementation Notes