drivers/input/touchscreen/wm9705.c
Source file repositories/reference/linux-study-clean/drivers/input/touchscreen/wm9705.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/touchscreen/wm9705.c- Extension
.c- Size
- 9243 bytes
- Lines
- 347
- Domain
- Driver Families
- Bucket
- drivers/input
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/module.hlinux/moduleparam.hlinux/kernel.hlinux/input.hlinux/delay.hlinux/bitops.hlinux/wm97xx.h
Detected Declarations
function poll_delayfunction wm9705_phy_initfunction wm9705_dig_enablefunction wm9705_aux_preparefunction wm9705_dig_restorefunction is_pdenfunction wm9705_poll_samplefunction wm9705_poll_touchfunction wm9705_acc_enableexport wm9705_codec
Annotated Snippet
if (delay < 0 || delay > 15) {
dev_dbg(wm->dev, "supplied delay out of range.");
delay = 4;
}
}
dig1 &= 0xff0f;
dig1 |= WM97XX_DELAY(delay);
dev_dbg(wm->dev, "setting adc sample delay to %d u Secs.",
delay_table[delay]);
/* WM9705 pdd */
dig2 |= (pdd & 0x000f);
dev_dbg(wm->dev, "setting pdd to Vmid/%d", 1 - (pdd & 0x000f));
/* mask */
dig2 |= ((mask & 0x3) << 4);
wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, dig1);
wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, dig2);
}
static void wm9705_dig_enable(struct wm97xx *wm, int enable)
{
if (enable) {
wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2,
wm->dig[2] | WM97XX_PRP_DET_DIG);
wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); /* dummy read */
} else
wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2,
wm->dig[2] & ~WM97XX_PRP_DET_DIG);
}
static void wm9705_aux_prepare(struct wm97xx *wm)
{
memcpy(wm->dig_save, wm->dig, sizeof(wm->dig));
wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, 0);
wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, WM97XX_PRP_DET_DIG);
}
static void wm9705_dig_restore(struct wm97xx *wm)
{
wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, wm->dig_save[1]);
wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER2, wm->dig_save[2]);
}
static inline int is_pden(struct wm97xx *wm)
{
return wm->dig[2] & WM9705_PDEN;
}
/*
* Read a sample from the WM9705 adc in polling mode.
*/
static int wm9705_poll_sample(struct wm97xx *wm, int adcsel, int *sample)
{
int timeout = 5 * delay;
bool wants_pen = adcsel & WM97XX_PEN_DOWN;
if (wants_pen && !wm->pen_probably_down) {
u16 data = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD);
if (!(data & WM97XX_PEN_DOWN))
return RC_PENUP;
wm->pen_probably_down = 1;
}
/* set up digitiser */
if (wm->mach_ops && wm->mach_ops->pre_sample)
wm->mach_ops->pre_sample(adcsel);
wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, (adcsel & WM97XX_ADCSEL_MASK)
| WM97XX_POLL | WM97XX_DELAY(delay));
/* wait 3 AC97 time slots + delay for conversion */
poll_delay(delay);
/* wait for POLL to go low */
while ((wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER1) & WM97XX_POLL)
&& timeout) {
udelay(AC97_LINK_FRAME);
timeout--;
}
if (timeout == 0) {
/* If PDEN is set, we can get a timeout when pen goes up */
if (is_pden(wm))
wm->pen_probably_down = 0;
else
dev_dbg(wm->dev, "adc sample timeout");
return RC_PENUP;
}
Annotation
- Immediate include surface: `linux/export.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/kernel.h`, `linux/input.h`, `linux/delay.h`, `linux/bitops.h`, `linux/wm97xx.h`.
- Detected declarations: `function poll_delay`, `function wm9705_phy_init`, `function wm9705_dig_enable`, `function wm9705_aux_prepare`, `function wm9705_dig_restore`, `function is_pden`, `function wm9705_poll_sample`, `function wm9705_poll_touch`, `function wm9705_acc_enable`, `export wm9705_codec`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.