Skip to contentSkip to conversation

INPUT: new ioctl's to retrieve values of EV_REP and EV_SND event codes

PATCH In review bjd 4 participants 14 messages Apr 22, 2006 – Apr 28, 2006 Input drivers

lore
Share & tools
lore

bjd

author
#0 lore raw

PATCH 1/1 INPUT: new ioctl's to retrieve values of EV_REP and EV_SND event codes

From: Bauke Jan Douma <[email protected]>

Add two new ioctl's to have the input driver return actual current values for EV_REP and EV_SND event codes.

Currently there is no ioctl to retrieve EV_REP values, even though they have actually always been stored in dev->rep. A new ioctl, EVIOCGREPCODE, retrieves them.

The existing EVCGSND ioctl has never returned anything meaningful; the relevant fragment in input.c was missing even a change_bit() call.
The actual EV_SND values are now written in dev->snd. To make this work, dev->snd had to be made an int array, and as a consequence the EVICGSND ioctl became problematic. I have removed it in this diff, but --even though it never has returned anything meaningful-- I'm not quite sure that's the right thing to do, so I would appreciate feedback on this.
Anyway, an EVIOCGSNDCODE ioctl was added to retrieve these values.

I have named the two ioctl's EVIOCGREPCODE and EVIOCGSNDCODE; I didn't want to use EVIOCGSND for obvious reasons, and since the ioctl's retrieve the value of an event _code_, I named them in this way, more or less analogue to EVIOCGKEYCODE -- after all the input driver works with type, code, value, which is nicely reflected in the naming and argument. Feedback appreciated though.

The ioctl's btw. currently work analoguous to EVIOCKEYCODE; they must be given an int[2] argument, where int[0] is exactly one event code (of the appropriate event type) of which the value is queried; the value will be returned in int[1].

---

Patch is against 2.6.16 proper.

linux/drivers/input/evdev.c renamed from linux/drivers/input/evdev.c.orig +18 -4
diff -uprN a/drivers/input/evdev.c b/drivers/input/evdev.c
@@ -407,6 +407,24 @@ static long evdev_ioctl_handler(struct f
 
 			return 0;
 
+		case EVIOCGREPCODE:
+			if (get_user(t, ip))
+				return -EFAULT;
+			if (t < 0 || t >= REP_MAX + 1)
+				return -EINVAL;
+			if (put_user(dev->rep[t], ip + 1))
+				return -EFAULT;
+			return 0;
+
+		case EVIOCGSNDCODE:
+			if (get_user(t, ip))
+				return -EFAULT;
+			if (t < 0 || t >= SND_MAX + 1)
+				return -EINVAL;
+			if (put_user(dev->snd[t], ip + 1))
+				return -EFAULT;
+			return 0;
+
 		case EVIOCGKEYCODE:
 			if (get_user(t, ip))
 				return -EFAULT;
@@ -513,10 +531,6 @@ static long evdev_ioctl_handler(struct f
 					return bits_to_user(dev->led, LED_MAX, _IOC_SIZE(cmd),
 							    p, compat_mode);
 
-				if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0)))
-					return bits_to_user(dev->snd, SND_MAX, _IOC_SIZE(cmd),
-							    p, compat_mode);
-
 				if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSW(0)))
 					return bits_to_user(dev->sw, SW_MAX, _IOC_SIZE(cmd),
 							    p, compat_mode);
linux/drivers/input/input.c renamed from linux/drivers/input/input.c.orig +1 -0
diff -uprN a/drivers/input/input.c b/drivers/input/input.c
@@ -153,6 +153,7 @@ void input_event(struct input_dev *dev, 
 			if (code > SND_MAX || !test_bit(code, dev->sndbit))
 				return;
 
+			dev->snd[code] = value;
 			if (dev->event) dev->event(dev, type, code, value);
 
 			break;
linux/include/linux/input.h renamed from linux/include/linux/input.h.orig +3 -2
diff -uprN a/include/linux/input.h b/include/linux/input.h
@@ -59,6 +59,8 @@ struct input_absinfo {
 #define EVIOCGVERSION		_IOR('E', 0x01, int)			/* get driver version */
 #define EVIOCGID		_IOR('E', 0x02, struct input_id)	/* get device ID */
 #define EVIOCGKEYCODE		_IOR('E', 0x04, int[2])			/* get keycode */
+#define EVIOCGREPCODE		_IOR('E', 0x10, int[2])			/* get an EV_REP setting */
+#define EVIOCGSNDCODE		_IOR('E', 0x11, int[2])			/* get an EV_SND setting */
 #define EVIOCSKEYCODE		_IOW('E', 0x04, int[2])			/* set keycode */
 
 #define EVIOCGNAME(len)		_IOC(_IOC_READ, 'E', 0x06, len)		/* get device name */
@@ -67,7 +69,6 @@ struct input_absinfo {
 
 #define EVIOCGKEY(len)		_IOC(_IOC_READ, 'E', 0x18, len)		/* get global keystate */
 #define EVIOCGLED(len)		_IOC(_IOC_READ, 'E', 0x19, len)		/* get all LEDs */
-#define EVIOCGSND(len)		_IOC(_IOC_READ, 'E', 0x1a, len)		/* get all sounds status */
 #define EVIOCGSW(len)		_IOC(_IOC_READ, 'E', 0x1b, len)		/* get all switch states */
 
 #define EVIOCGBIT(ev,len)	_IOC(_IOC_READ, 'E', 0x20 + ev, len)	/* get event bits */
@@ -908,10 +909,10 @@ struct input_dev {
 
 	int abs[ABS_MAX + 1];
 	int rep[REP_MAX + 1];
+	int snd[SND_MAX + 1];
 
 	unsigned long key[NBITS(KEY_MAX)];
 	unsigned long led[NBITS(LED_MAX)];
-	unsigned long snd[NBITS(SND_MAX)];
 	unsigned long sw[NBITS(SW_MAX)];
 
 	int absmax[ABS_MAX + 1];
maintainer
#1 lore raw
Quoted 3 lines · bjd

From: Bauke Jan Douma <[email protected]>

Hi Bauke,

Thank you for your patch.

Quoted 7 lines

Add two new ioctl's to have the input driver return actual current values for EV_REP and EV_SND event codes.

Currently there is no ioctl to retrieve EV_REP values, even though they have actually always been stored in dev->rep. A new ioctl, EVIOCGREPCODE, retrieves them.

EVIOCGREP and EVIOCSREP ioctls are present in 2.4 but they have been removed during 2.6 development. If you need to get/set repeat delay and period you need to use KDKBDREP ioctl; it will change the repeat rate for all keyboards attached to the box.

Vojtech, could you remind me why EVIOC{G|S}REP were removed? Some people want to have ability to separate keyboards (via grabbing); they also might want to control repeat rate independently. Shoudl we reinstate these ioctls?

Quoted 8 lines

The existing EVCGSND ioctl has never returned anything meaningful; the relevant fragment in input.c was missing even a change_bit() call.
The actual EV_SND values are now written in dev->snd. To make this work, dev->snd had to be made an int array, and as a consequence the EVICGSND ioctl became problematic. I have removed it in this diff, but --even though it never has returned anything meaningful-- I'm not quite sure that's the right thing to do, so I would appreciate feedback on this.
Anyway, an EVIOCGSNDCODE ioctl was added to retrieve these values.

I think we should just fix EVCGSND and just allow userspace to query which sound evvects are active fro device - IOW just return bitmap like we do for keys and leds and switches. I don't think actuall "value" of the SND_TONE is interesting to anyone.

--
Dmitry

#2 lore raw
Quoted 22 lines · Dmitry Torokhov
Quoted 3 lines · bjd

From: Bauke Jan Douma <[email protected]>

Hi Bauke,

Thank you for your patch.

Quoted 7 lines

Add two new ioctl's to have the input driver return actual current values for EV_REP and EV_SND event codes.

Currently there is no ioctl to retrieve EV_REP values, even though they have actually always been stored in dev->rep. A new ioctl, EVIOCGREPCODE, retrieves them.

EVIOCGREP and EVIOCSREP ioctls are present in 2.4 but they have been removed during 2.6 development. If you need to get/set repeat delay and period you need to use KDKBDREP ioctl; it will change the repeat rate for all keyboards attached to the box.

Quoted 4 lines

Vojtech, could you remind me why EVIOC{G|S}REP were removed? Some people want to have ability to separate keyboards (via grabbing); they also might want to control repeat rate independently. Shoudl we reinstate these ioctls?

I believe they were replaced by the ability to send EV_REP style events to the device, setting the repeat rate.

Quoted 9 lines
Quoted 8 lines

The existing EVCGSND ioctl has never returned anything meaningful; the relevant fragment in input.c was missing even a change_bit() call.
The actual EV_SND values are now written in dev->snd. To make this work, dev->snd had to be made an int array, and as a consequence the EVICGSND ioctl became problematic. I have removed it in this diff, but --even though it never has returned anything meaningful-- I'm not quite sure that's the right thing to do, so I would appreciate feedback on this.
Anyway, an EVIOCGSNDCODE ioctl was added to retrieve these values.

Quoted 4 lines

I think we should just fix EVCGSND and just allow userspace to query which sound evvects are active fro device - IOW just return bitmap like we do for keys and leds and switches. I don't think actuall "value" of the SND_TONE is interesting to anyone.

Agreed.

Signature · 2 lines
Vojtech Pavlik
Director SuSE Labs
maintainer
#3 lore raw
Quoted 10 lines · Vojtech Pavlik
Quoted 5 lines · Dmitry Torokhov

Vojtech, could you remind me why EVIOC{G|S}REP were removed? Some people want to have ability to separate keyboards (via grabbing); they also might want to control repeat rate independently. Shoudl we reinstate these ioctls?

I believe they were replaced by the ability to send EV_REP style events to the device, setting the repeat rate.

Argh, why am I always forgetting about ability to write events into devices?

--
Dmitry

maintainer
#4 lore raw
Quoted 8 lines · Dmitry Torokhov
Quoted 7 lines · Vojtech Pavlik
Quoted 5 lines · Dmitry Torokhov

Vojtech, could you remind me why EVIOC{G|S}REP were removed? Some people want to have ability to separate keyboards (via grabbing); they also might want to control repeat rate independently. Shoudl we reinstate these ioctls?

Quoted 6 lines
Quoted 3 lines

I believe they were replaced by the ability to send EV_REP style events to the device, setting the repeat rate.

Argh, why am I always forgetting about ability to write events into devices?

Thinking about it some more - writing to the event device is an elegant way to set repeat rate but how do you retrieve current repeat rate for a given device?

--
Dmitry

#5 lore raw
Quoted 13 lines · Dmitry Torokhov
Quoted 12 lines · Dmitry Torokhov
Quoted 10 lines · Vojtech Pavlik
Quoted 5 lines · Dmitry Torokhov

Vojtech, could you remind me why EVIOC{G|S}REP were removed? Some people want to have ability to separate keyboards (via grabbing); they also might want to control repeat rate independently. Shoudl we reinstate these ioctls?

I believe they were replaced by the ability to send EV_REP style events to the device, setting the repeat rate.

Quoted 5 lines
Quoted 1 line

Argh, why am I always forgetting about ability to write events into devices?

Thinking about it some more - writing to the event device is an elegant way to set repeat rate but how do you retrieve current repeat rate for a given device?

You can't. And that's likely a problem that needs fixing.

Signature · 2 lines
Vojtech Pavlik
Director SuSE Labs
maintainer
#6 lore raw
Quoted 14 lines · Vojtech Pavlik
Quoted 13 lines · Dmitry Torokhov
Quoted 12 lines · Dmitry Torokhov
Quoted 10 lines · Vojtech Pavlik
Quoted 5 lines · Dmitry Torokhov

Vojtech, could you remind me why EVIOC{G|S}REP were removed? Some people want to have ability to separate keyboards (via grabbing); they also might want to control repeat rate independently. Shoudl we reinstate these ioctls?

I believe they were replaced by the ability to send EV_REP style events to the device, setting the repeat rate.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Argh, why am I always forgetting about ability to write events into devices?

Thinking about it some more - writing to the event device is an elegant way to set repeat rate but how do you retrieve current repeat rate for a given device?

You can't. And that's likely a problem that needs fixing.

So do you agree that we need to ressurect EVIOCGREP (and EVIOCSREP just to complement the interface)?

--
Dmitry

#7 lore raw
Quoted 21 lines · Dmitry Torokhov
Quoted 20 lines · Vojtech Pavlik
Quoted 18 lines · Dmitry Torokhov
Quoted 8 lines · Dmitry Torokhov
Quoted 7 lines · Vojtech Pavlik
Quoted 5 lines · Dmitry Torokhov

Vojtech, could you remind me why EVIOC{G|S}REP were removed? Some people want to have ability to separate keyboards (via grabbing); they also might want to control repeat rate independently. Shoudl we reinstate these ioctls?

Quoted 5 lines
Quoted 3 lines

I believe they were replaced by the ability to send EV_REP style events to the device, setting the repeat rate.

Argh, why am I always forgetting about ability to write events into devices?

Thinking about it some more - writing to the event device is an elegant way to set repeat rate but how do you retrieve current repeat rate for a given device?

Quoted 5 lines
Quoted 2 lines

You can't. And that's likely a problem that needs fixing.

So do you agree that we need to ressurect EVIOCGREP (and EVIOCSREP just to complement the interface)?

Yes. And EVIOCSREP should just generate the events needed to notify the drivers to do the change.

Signature · 2 lines
Vojtech Pavlik
Director SuSE Labs
#8 lore raw
Quoted 22 lines · Vojtech Pavlik
Quoted 21 lines · Dmitry Torokhov
Quoted 20 lines · Vojtech Pavlik
Quoted 18 lines · Dmitry Torokhov
Quoted 8 lines · Dmitry Torokhov
Quoted 7 lines · Vojtech Pavlik
Quoted 5 lines · Dmitry Torokhov

Vojtech, could you remind me why EVIOC{G|S}REP were removed? Some people want to have ability to separate keyboards (via grabbing); they also might want to control repeat rate independently. Shoudl we reinstate these ioctls?

Quoted 5 lines
Quoted 3 lines

I believe they were replaced by the ability to send EV_REP style events to the device, setting the repeat rate.

Argh, why am I always forgetting about ability to write events into devices?

Thinking about it some more - writing to the event device is an elegant way to set repeat rate but how do you retrieve current repeat rate for a given device?

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

You can't. And that's likely a problem that needs fixing.

So do you agree that we need to ressurect EVIOCGREP (and EVIOCSREP just to complement the interface)?

Yes. And EVIOCSREP should just generate the events needed to notify the drivers to do the change.

What do you gius think about the patch below?

Signature · 53 lines
Dmitry

Signed-off-by: Dmitry Torokhov <[email protected]>
---

 drivers/input/evdev.c |   21 +++++++++++++++++++++
 include/linux/input.h |    2 ++
 2 files changed, 23 insertions(+)

Index: work/drivers/input/evdev.c
===================================================================
--- work.orig/drivers/input/evdev.c
+++ work/drivers/input/evdev.c
@@ -403,6 +403,27 @@ static long evdev_ioctl_handler(struct f
 		case EVIOCGID:
 			if (copy_to_user(p, &dev->id, sizeof(struct input_id)))
 				return -EFAULT;
+			return 0;
+
+		case EVIOCGREP:
+			if (!test_bit(EV_REP, dev->evbit))
+				return -ENOSYS;
+			if (put_user(dev->rep[REP_DELAY], ip))
+				return -EFAULT;
+			if (put_user(dev->rep[REP_PERIOD], ip + 1))
+				return -EFAULT;
+			return 0;
+
+		case EVIOCSREP:
+			if (!test_bit(EV_REP, dev->evbit))
+				return -ENOSYS;
+			if (get_user(u, ip))
+				return -EFAULT;
+			if (get_user(v, ip + 1))
+				return -EFAULT;
+
+			input_event(dev, EV_REP, REP_DELAY, u);
+			input_event(dev, EV_REP, REP_PERIOD, v);
 
 			return 0;
 
Index: work/include/linux/input.h
===================================================================
--- work.orig/include/linux/input.h
+++ work/include/linux/input.h
@@ -56,6 +56,8 @@ struct input_absinfo {
 
 #define EVIOCGVERSION		_IOR('E', 0x01, int)			/* get driver version */
 #define EVIOCGID		_IOR('E', 0x02, struct input_id)	/* get device ID */
+#define EVIOCGREP		_IOR('E', 0x03, int[2])			/* get repeat settings */
+#define EVIOCSREP		_IOW('E', 0x03, int[2])			/* get repeat settings */
 #define EVIOCGKEYCODE		_IOR('E', 0x04, int[2])			/* get keycode */
 #define EVIOCSKEYCODE		_IOW('E', 0x04, int[2])			/* set keycode */
#9 lore raw
Quoted 5 lines · Dmitry Torokhov
Quoted 3 lines

Yes. And EVIOCSREP should just generate the events needed to notify the drivers to do the change.

What do you gius think about the patch below?

It looks fine to me.

Quoted 57 lines
Signature · 11 lines
Dmitry

Signed-off-by: Dmitry Torokhov <[email protected]>
---

 drivers/input/evdev.c |   21 +++++++++++++++++++++
 include/linux/input.h |    2 ++
 2 files changed, 23 insertions(+)

Index: work/drivers/input/evdev.c
===================================================================
drivers/input/evdev.c +21 -0
@@ -403,6 +403,27 @@ static long evdev_ioctl_handler(struct f
 		case EVIOCGID:
 			if (copy_to_user(p, &dev->id, sizeof(struct input_id)))
 				return -EFAULT;
+			return 0;
+
+		case EVIOCGREP:
+			if (!test_bit(EV_REP, dev->evbit))
+				return -ENOSYS;
+			if (put_user(dev->rep[REP_DELAY], ip))
+				return -EFAULT;
+			if (put_user(dev->rep[REP_PERIOD], ip + 1))
+				return -EFAULT;
+			return 0;
+
+		case EVIOCSREP:
+			if (!test_bit(EV_REP, dev->evbit))
+				return -ENOSYS;
+			if (get_user(u, ip))
+				return -EFAULT;
+			if (get_user(v, ip + 1))
+				return -EFAULT;
+
+			input_event(dev, EV_REP, REP_DELAY, u);
+			input_event(dev, EV_REP, REP_PERIOD, v);
 
 			return 0;
 

Index: work/include/linux/input.h
===================================================================

include/linux/input.h +2 -0
@@ -56,6 +56,8 @@ struct input_absinfo {
 
 #define EVIOCGVERSION		_IOR('E', 0x01, int)			/* get driver version */
 #define EVIOCGID		_IOR('E', 0x02, struct input_id)	/* get device ID */
+#define EVIOCGREP		_IOR('E', 0x03, int[2])			/* get repeat settings */
+#define EVIOCSREP		_IOW('E', 0x03, int[2])			/* get repeat settings */
 #define EVIOCGKEYCODE		_IOR('E', 0x04, int[2])			/* get keycode */
 #define EVIOCSKEYCODE		_IOW('E', 0x04, int[2])			/* set keycode */
 
Signature · 2 lines
Vojtech Pavlik
Director SuSE Labs
author
#10 lore raw
In reply to Dmitry Torokhov
Quoted 1 line · Dmitry Torokhov

What do you gius think about the patch below?

Works like a charm.
Why is it though that we need EVIOCSREP, when I can set PERIOD and DELAY through writing a struct input_event directly to the file descriptor? I've been doing that for quite some time, having softrepeat=1 (I need a quick keyboard, DELAY=120, PERIOD=18).

One typo in the patch:
+#define EVIOCSREP _IOW('E', 0x03, int[2]) /* get repeat settings */
should be:
+#define EVIOCSREP _IOW('E', 0x03, int[2]) /* set repeat settings */

Now, the EV_SND bitmap is still broken.
I don't think it's simply a matter of adding change_bit(code,dev->snd) in the EV_SND part of input.c. During a quick test the bitmap became confused, after setting both bell and tone through writing a struct input_event to the file descriptor of the pcspkr's event file in /dev/input/, then setting just bell to 0.

bjd

maintainer
#11 lore raw
Quoted 10 lines · bjdouma
Quoted 1 line · Dmitry Torokhov

What do you gius think about the patch below?

Works like a charm.
Why is it though that we need EVIOCSREP, when I can set PERIOD and DELAY through writing a struct input_event directly to the file descriptor? I've been doing that for quite some time, having softrepeat=1 (I need a quick keyboard, DELAY=120, PERIOD=18).

Quoted 5 lines

One typo in the patch:
+#define EVIOCSREP _IOW('E', 0x03, int[2]) /* get repeat settings */
should be:
+#define EVIOCSREP _IOW('E', 0x03, int[2]) /* set repeat settings */

Ah, OK, thanks, I will fix that.

Quoted 7 lines

Now, the EV_SND bitmap is still broken.
I don't think it's simply a matter of adding change_bit(code,dev->snd) in the EV_SND part of input.c. During a quick test the bitmap became confused, after setting both bell and tone through writing a struct input_event to the file descriptor of the pcspkr's event file in /dev/input/, then setting just bell to 0.

Are you saying that both bits were set to 0 or that you could not hear the tone after killing bell? If latter then it is sort of pcspkr problem as from input core POV tone is still active.

Btw, your patch - did it resemble something like attached?

--
Dmitry

Input: make EVIOCGSND return meaningful data

---
 drivers/input/input.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/input/input.c +3 -0
Index: linux/drivers/input/input.c
===================================================================
@@ -155,6 +155,9 @@ void input_event(struct input_dev *dev, 
 			if (code > SND_MAX || !test_bit(code, dev->sndbit))
 				return;
 
+			if (!!test_bit(code, dev->snd) != !!value)
+				change_bit(code, dev->snd);
+
 			if (dev->event) dev->event(dev, type, code, value);
 
 			break;
author
#12 lore raw
Quoted 11 lines · Dmitry Torokhov

Are you saying that both bits were set to 0 or that you could not hear the tone after killing bell? If latter then it is sort of pcspkr problem as from input core POV tone is still active.

Btw, your patch - did it resemble something like attached?

Index: linux/drivers/input/input.c
===================================================================

drivers/input/input.c void input_event(struct input_dev *dev, · line 163

Quoted 9 lines
drivers/input/input.c +3 -0
@@ -155,6 +155,9 @@ void input_event(struct input_dev *dev, 
 			if (code > SND_MAX || !test_bit(code, dev->sndbit))
 				return;
 
+			if (!!test_bit(code, dev->snd) != !!value)
+				change_bit(code, dev->snd);
+
 			if (dev->event) dev->event(dev, type, code, value);
 
 			break;

Before I made the change of dev->snd to an int array, yes it did exactly this same thing.

Basically what I'm saying is that when you query the input driver for the state of EV_SND, it doesn't tell you much about what tone is actually audible, if at all.

Let me give two examples. I am using here my program inputcntrl that I am working on -- basically a wrapper with a parser and interpreter around some of the uinput driver's functions (if you want a copy of the WIP tree, let me know).

Just regard both examples as a complete session, i.e. no other commands influencing the pcspkr are interspersed in what you see below (/dev/input/pcspkr happens to be a symlink to /dev/input/event1).

These examples are with your latest small patch in place, the one doing the change_bit(code, dev->snd).

Example i.

$> inputcntrl -d /dev/input/pcspkr set-snd 'bell=0;tone=0' # part 1; reset
$> inputcntrl -d /dev/input/pcspkr set-snd bell=1 $> inputcntrl -d /dev/input/pcspkr get-snd bell,tone
SND_BELL 1
SND_TONE 0
tone 1000Hz, see pcspkr.c

$> inputcntrl -d /dev/input/pcspkr set-snd tone=1200
$> inputcntrl -d /dev/input/pcspkr get-snd bell,tone
SND_BELL 1
SND_TONE 1
tone 1200Hz
note that bell remains 1
ok, let's conclude that if bell=1 then sound=1000Hz unless tone=1

$> inputcntrl -d /dev/input/pcspkr set-snd 'bell=0;tone0' # part 2; reset
$> inputcntrl -d /dev/input/pcspkr set-snd tone=1200 $> inputcntrl -d /dev/input/pcspkr get-snd bell,tone
SND_BELL 0
SND_TONE 1

	tone 1200Hz

$> inputcntrl -d /dev/input/pcspkr set-snd bell=1 $> inputcntrl -d /dev/input/pcspkr get-snd bell,tone
SND_BELL 1
SND_TONE 1
tone 1000Hz
oddness: state of EV_SND (1,1) is same as in part 1, only now is sound a tone of 1000Hz. conclusion in part 1 apparently wrong.
so when state is (1,1), actual sound can be anything

Example ii.

$> inputcntrl -d /dev/input/pcspkr set-snd 'bell=0;tone=0' # part 3; reset
$> inputcntrl -d /dev/input/pcspkr set-snd tone=1200 inputcntrl -d /dev/input/pcspkr get-snd bell,tone
SND_BELL 0
SND_TONE 1

	tone 1200Hz

$> inputcntrl -d /dev/input/pcspkr set-snd bell=1 $> inputcntrl -d /dev/input/pcspkr get-snd bell,tone
SND_BELL 1
SND_TONE 1

	tone 1000Hz

$> inputcntrl -d /dev/input/pcspkr set-snd bell=0 $> inputcntrl -d /dev/input/pcspkr get-snd bell,tone
SND_BELL 0
SND_TONE 1
silence!, but SND_TONE = 1!
on top of that, state is same as in part 2, only then we heard a tone of 1200Hz, now we have silence

bjd

maintainer
#13 lore raw
Quoted 5 lines · bjdouma

Basically what I'm saying is that when you query the input driver for the state of EV_SND, it doesn't tell you much about what tone is actually audible, if at all.

I agree but I still questinon usefullness of that data.

Quoted 5 lines

Let me give two examples. I am using here my program inputcntrl that I am working on -- basically a wrapper with a parser and interpreter around some of the uinput driver's functions (if you want a copy of the WIP tree, let me know).

Quoted 7 lines

Just regard both examples as a complete session, i.e. no other commands influencing the pcspkr are interspersed in what you see below (/dev/input/pcspkr happens to be a symlink to /dev/input/event1).

These examples are with your latest small patch in place, the one doing the change_bit(code, dev->snd).

<..skipped..>

OK, so the first example illustrates that input core does not provide "tone" data - no surprise here. The scond example proves that pcspkr driver does not handle concurrent access very well. Still the input core behaved exactly as it was supposed to, everythng is fine as far as I can see.

--
Dmitry