summaryrefslogtreecommitdiffstats
path: root/source/l/libieee1284/libieee1284-add-more-python-bindings.patch
blob: eea4cb4fc73ba8cdc23f152952f198c1352dc4e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
From b4d63327dfef8dbf12aabf4bba0f6818a3519995 Mon Sep 17 00:00:00 2001
From: Tim Waugh <twaugh@redhat.com>
Date: Tue, 8 Mar 2011 15:07:04 +0000
Subject: [PATCH] 2011-03-08  Tim Waugh  <twaugh@redhat.com>

* src/ieee1284module.c: Added bindings for get_irq_fd and
clear_irq.  Patch by Sergey Temerkhanov.
---
 src/ieee1284module.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/src/ieee1284module.c b/src/ieee1284module.c
index 0093d6f..23c1f29 100644
--- a/src/ieee1284module.c
+++ b/src/ieee1284module.c
@@ -189,6 +189,33 @@ Parport_open (ParportObject *self, PyObject *args)
 	return PyInt_FromLong (capabilities);
 }
 
+static PyObject *
+Parport_get_irq_fd (ParportObject *self)
+{
+	int fd = ieee1284_get_irq_fd (self->port);
+	if (fd < 0) {
+		handle_error (fd);
+		return NULL;
+	}
+
+	return PyInt_FromLong (fd);
+}
+
+static PyObject *
+Parport_clear_irq (ParportObject *self)
+{
+	int portcount = 0;
+	int r;
+
+	int fd = ieee1284_clear_irq (self->port, &portcount);
+	if (r < 0) {
+		handle_error (r);
+		return NULL;
+	}
+
+	return PyInt_FromLong (portcount);
+}
+
 static PyObject *
 Parport_close (ParportObject *self)
 {
@@ -484,6 +511,12 @@ PyMethodDef Parport_methods[] = {
 	{ "close", (PyCFunction) Parport_close, METH_NOARGS,
 	  "close() -> None\n"
 	  "Closes a port." },
+	{ "get_irq_fd", (PyCFunction) Parport_get_irq_fd, METH_VARARGS,
+	  "get_irq_fd() -> int\n"
+	  "Returns a pollable IRQ file descriptor." },
+	{ "clear_irq", (PyCFunction) Parport_clear_irq, METH_NOARGS,
+	  "clear_irq(portcount) -> int\n"
+	  "Clears IRQ and returns number of IRQs raised." },
 	{ "claim", (PyCFunction) Parport_claim, METH_NOARGS,
 	  "claim() -> None\n"
 	  "Claims a port." },