[Linux device driver] Keypad interrupt latency 문제 해결 방법

andykim17의 이미지

안녕하세요?

고수님들의 조언을 구하고자 합니다.

System에 Keypad(10개 이상의 정전방식 keypad)를 사용하고 있습니다.
Key가 눌려지거나 release되면 interrupt가 발생하는데요.
release될 경우에 해당 key 값이 application에 최종 전달되게 되어 있습니다.
아래 해당 코드 참조...

=========================================================================

static irqreturn_t unitron_interrupt(int irq, void *dev_id)
{
	struct unitron_data *data = dev_id;
	struct i2c_client *client = data->client;
	struct input_dev *input = data->input;
	int i;
	u8 key_low, key_high;
	u16 rawkey, keyval, mask = 0x01;
	u32 led		=	KEYPAD_LED;
 
	/* Read which key changed */
	rawkey = unitron_read(client, TC_MON_HIGH_REG);
	key_low = (rawkey>>8)&0xff;
	key_high = (rawkey)&0xff;
	rawkey = (key_high<<8)|(key_low);
 
	if(rawkey == 0x00){
		rawkey = data->last_keys;
		for (i = 0; i < ARRAY_SIZE(unitron_key2code); i++) {
			keyval = rawkey & mask;
			keyval >>= i;
			if (keyval){
				input_report_key(input, data->keycodes[i], 0);
			}
			mask <<= 1;
		}
	}
	else {
		for (i = 0; i < ARRAY_SIZE(unitron_key2code); i++) {
			keyval = rawkey & mask;
			keyval >>= i;
			if (keyval){
				input_report_key(input, data->keycodes[i], 1);
			}
			mask <<= 1;
		}
	}
	input_sync(input);
 
	data->last_keys = rawkey;
	return IRQ_HANDLED;
}

=========================================================================

문제는 key touch-release를 천천히 하면 touch-release된 key값을 정상적으로 application에 전달하나
상당히 빨리 하면 key값을 놓친다는 것입니다.
문제의 원인은 touch시의 interrupt 처리가 다 끝나지 않은 상태에서 release가 되어 이를 인식하지 못한다는
것입니다. 즉 interrupt latency 문제가 아닌가 생각됩니다.

이를 해결하기 위한 방법으로 어떤 것이 있을까요?

고언 부탁드립니다.

라스코니의 이미지

key가 눌려지는 이벤트를 저장하는 버퍼가 어떤 구조인지는 모르겠지만 인터럽트시 1개가 아닌 2개 이상의 이벤트가 들어있을 수 있는 구조로 되어 있는 경우가 있습니다. 그럴 때는 인터럽트 핸들러에서 현재 이벤트 큐가 가지고 있는 개수를 확인하여 그만큼 처리해 주어야 key 이벤트를 놓치지 않습니다.

또 input_report_key() 함수가 무슨 일을 하는지 모르겠지만 이 처리 과정에서 많은 시간이 소요되면 그 사이에 발생하는 다른 key 이벤트를 놓칠 수 있습니다.

furmuwon의 이미지

bottom half 방식으로 작성을 해보세요.
인터럽트 핸들러 등록하는 부분은 보이질 않아서.. 알수 없지만
hardirq 핸들러에서 이런 행동을 하고 계시면 굉장히 부담스럽습니다.

이 디바이스 드라이버 레퍼런스 삼아서 한번 작성해 보세요
http://elixir.free-electrons.com/linux/v4.8/source/drivers/input/touchscreen/tsc2007.c

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.