Skip to contentSkip to conversation

Sonypi: convert to the new platform device interface

RFT Dmitry Torokhov 5 participants 15 messages Dec 13, 2005 – Jan 16, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

Now that we allow manual binding and unbinding devices through sysfs it is better if main device initialization is done in ->probe() instead of module_init(). The following patch converts sonypi driver to this model.

The patch compiles but I was unable to test it since I don't have the hardware...

Signature · 502 lines
Dmitry

Sonypi: convert to the new platform device interface

Do not use platform_device_register_simple() as it is going away,
implement ->probe() and -remove() functions so manual binding and
unbinding would work.

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

Index: work/drivers/char/sonypi.c
===================================================================
--- work.orig/drivers/char/sonypi.c
+++ work/drivers/char/sonypi.c
@@ -471,7 +471,6 @@ struct sonypi_keypress {
 
 static struct sonypi_device {
 	struct pci_dev *dev;
-	struct platform_device *pdev;
 	u16 irq;
 	u16 bits;
 	u16 ioport1;
@@ -1165,45 +1164,12 @@ static int sonypi_disable(void)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int old_camera_power;
-
-static int sonypi_suspend(struct platform_device *dev, pm_message_t state)
-{
-	old_camera_power = sonypi_device.camera_power;
-	sonypi_disable();
-
-	return 0;
-}
-
-static int sonypi_resume(struct platform_device *dev)
-{
-	sonypi_enable(old_camera_power);
-	return 0;
-}
-#endif
-
-static void sonypi_shutdown(struct platform_device *dev)
-{
-	sonypi_disable();
-}
-
-static struct platform_driver sonypi_driver = {
-#ifdef CONFIG_PM
-	.suspend	= sonypi_suspend,
-	.resume		= sonypi_resume,
-#endif
-	.shutdown	= sonypi_shutdown,
-	.driver		= {
-		.name	= "sonypi",
-	},
-};
-
 static int __devinit sonypi_create_input_devices(void)
 {
 	struct input_dev *jog_dev;
 	struct input_dev *key_dev;
 	int i;
+	int error;
 
 	sonypi_device.input_jog_dev = jog_dev = input_allocate_device();
 	if (!jog_dev)
@@ -1219,9 +1185,8 @@ static int __devinit sonypi_create_input
 
 	sonypi_device.input_key_dev = key_dev = input_allocate_device();
 	if (!key_dev) {
-		input_free_device(jog_dev);
-		sonypi_device.input_jog_dev = NULL;
-		return -ENOMEM;
+		error = -ENOMEM;
+		goto err_free_jogdev;
 	}
 
 	key_dev->name = "Sony Vaio Keys";
@@ -1234,56 +1199,122 @@ static int __devinit sonypi_create_input
 		if (sonypi_inputkeys[i].inputev)
 			set_bit(sonypi_inputkeys[i].inputev, key_dev->keybit);
 
-	input_register_device(jog_dev);
-	input_register_device(key_dev);
+	error = input_register_device(jog_dev);
+	if (error)
+		goto err_free_keydev;
+
+	error = input_register_device(key_dev);
+	if (error)
+		goto err_unregister_jogdev;
 
 	return 0;
+
+ err_unregister_jogdev:
+	input_unregister_device(jog_dev);
+	/* Set to NULL so we don't free it again below */
+	jog_dev = NULL;
+ err_free_keydev:
+	input_free_device(key_dev);
+	sonypi_device.input_key_dev = NULL;
+ err_free_jogdev:
+	input_unregister_device(jog_dev);
+	sonypi_device.input_jog_dev = NULL;
+
+	return error;
 }
 
-static int __devinit sonypi_probe(void)
+static int __devinit sonypi_setup_ioports(struct sonypi_device *dev,
+				const struct sonypi_ioport_list *ioport_list)
 {
-	int i, ret;
-	struct sonypi_ioport_list *ioport_list;
-	struct sonypi_irq_list *irq_list;
-	struct pci_dev *pcidev;
+	while (ioport_list->port1) {
 
-	if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
-				     PCI_DEVICE_ID_INTEL_82371AB_3, NULL)))
-		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE1;
-	else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
-					  PCI_DEVICE_ID_INTEL_ICH6_1, NULL)))
-		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE3;
-	else
-		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE2;
+		if (request_region(ioport_list->port1,
+				   sonypi_device.region_size,
+				   "Sony Programable I/O Device")) {
+			dev->ioport1 = ioport_list->port1;
+			dev->ioport2 = ioport_list->port2;
+			return 0;
+		}
+		ioport_list++;
+	}
 
-	sonypi_device.dev = pcidev;
+	return -EBUSY;
+}
+
+static int __devinit sonypi_setup_irq(struct sonypi_device *dev,
+				      const struct sonypi_irq_list *irq_list)
+{
+	while (irq_list->irq) {
+
+		if (!request_irq(dev->irq, sonypi_irq,
+				 SA_SHIRQ, "sonypi", sonypi_irq)) {
+			dev->irq = irq_list->irq;
+			dev->bits = irq_list->bits;
+			return 0;
+		}
+		irq_list++;
+	}
+
+	return -EBUSY;
+}
+
+static void __devinit sonypi_display_info(void)
+{
+	printk(KERN_INFO "sonypi: detected type%d model, "
+	       "verbose = %d, fnkeyinit = %s, camera = %s, "
+	       "compat = %s, mask = 0x%08lx, useinput = %s, acpi = %s\n",
+	       sonypi_device.model,
+	       verbose,
+	       fnkeyinit ? "on" : "off",
+	       camera ? "on" : "off",
+	       compat ? "on" : "off",
+	       mask,
+	       useinput ? "on" : "off",
+	       SONYPI_ACPI_ACTIVE ? "on" : "off");
+	printk(KERN_INFO "sonypi: enabled at irq=%d, port1=0x%x, port2=0x%x\n",
+	       sonypi_device.irq,
+	       sonypi_device.ioport1, sonypi_device.ioport2);
+
+	if (minor == -1)
+		printk(KERN_INFO "sonypi: device allocated minor is %d\n",
+		       sonypi_misc_device.minor);
+}
+
+static int __devinit sonypi_probe(struct platform_device *dev)
+{
+	const struct sonypi_ioport_list *ioport_list;
+	const struct sonypi_irq_list *irq_list;
+	struct pci_dev *pcidev;
+	int error;
 
 	spin_lock_init(&sonypi_device.fifo_lock);
 	sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
 					 &sonypi_device.fifo_lock);
 	if (IS_ERR(sonypi_device.fifo)) {
 		printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
-		ret = PTR_ERR(sonypi_device.fifo);
-		goto out_fifo;
+		return PTR_ERR(sonypi_device.fifo);
 	}
 
 	init_waitqueue_head(&sonypi_device.fifo_proc_list);
 	init_MUTEX(&sonypi_device.lock);
 	sonypi_device.bluetooth_power = -1;
 
+	if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
+				     PCI_DEVICE_ID_INTEL_82371AB_3, NULL)))
+		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE1;
+	else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
+					  PCI_DEVICE_ID_INTEL_ICH6_1, NULL)))
+		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE3;
+	else
+		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE2;
+
 	if (pcidev && pci_enable_device(pcidev)) {
 		printk(KERN_ERR "sonypi: pci_enable_device failed\n");
-		ret = -EIO;
-		goto out_pcienable;
-	}
-
-	if (minor != -1)
-		sonypi_misc_device.minor = minor;
-	if ((ret = misc_register(&sonypi_misc_device))) {
-		printk(KERN_ERR "sonypi: misc_register failed\n");
-		goto out_miscreg;
+		error = -EIO;
+		goto err_free_fifo;
 	}
 
+	sonypi_device.dev = pcidev;
 
 	if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE1) {
 		ioport_list = sonypi_type1_ioport_list;
@@ -1302,43 +1333,31 @@ static int __devinit sonypi_probe(void)
 		irq_list = sonypi_type3_irq_list;
 	}
 
-	for (i = 0; ioport_list[i].port1; i++) {
-		if (request_region(ioport_list[i].port1,
-				   sonypi_device.region_size,
-				   "Sony Programable I/O Device")) {
-			/* get the ioport */
-			sonypi_device.ioport1 = ioport_list[i].port1;
-			sonypi_device.ioport2 = ioport_list[i].port2;
-			break;
-		}
+	error = sonypi_setup_ioports(&sonypi_device, ioport_list);
+	if (error) {
+		printk(KERN_ERR "sonypi: failed to request ioports\n");
+		goto err_disable_pcidev;
 	}
-	if (!sonypi_device.ioport1) {
-		printk(KERN_ERR "sonypi: request_region failed\n");
-		ret = -ENODEV;
-		goto out_reqreg;
-	}
-
-	for (i = 0; irq_list[i].irq; i++) {
-
-		sonypi_device.irq = irq_list[i].irq;
-		sonypi_device.bits = irq_list[i].bits;
 
-		if (!request_irq(sonypi_device.irq, sonypi_irq,
-				 SA_SHIRQ, "sonypi", sonypi_irq))
-			break;
+	error = sonypi_setup_irq(&sonypi_device, irq_list);
+	if (error) {
+		printk(KERN_ERR "sonypi: request_irq failed\n");
+		goto err_free_ioports;
 	}
 
-	if (!irq_list[i].irq) {
-		printk(KERN_ERR "sonypi: request_irq failed\n");
-		ret = -ENODEV;
-		goto out_reqirq;
+	if (minor != -1)
+		sonypi_misc_device.minor = minor;
+	error = misc_register(&sonypi_misc_device);
+	if (error) {
+		printk(KERN_ERR "sonypi: misc_register failed\n");
+		goto err_free_irq;
 	}
 
 	if (useinput) {
 
-		ret = sonypi_create_input_devices();
-		if (ret)
-			goto out_inputdevices;
+		error = sonypi_create_input_devices();
+		if (error)
+			goto err_miscdev_unregister;
 
 		spin_lock_init(&sonypi_device.input_fifo_lock);
 		sonypi_device.input_fifo =
@@ -1346,90 +1365,105 @@ static int __devinit sonypi_probe(void)
 				    &sonypi_device.input_fifo_lock);
 		if (IS_ERR(sonypi_device.input_fifo)) {
 			printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
-			ret = PTR_ERR(sonypi_device.input_fifo);
-			goto out_infifo;
+			error = PTR_ERR(sonypi_device.input_fifo);
+			goto err_inpdev_unregister;
 		}
 
 		INIT_WORK(&sonypi_device.input_work, input_keyrelease, NULL);
 	}
 
-	sonypi_device.pdev = platform_device_register_simple("sonypi", -1,
-							     NULL, 0);
-	if (IS_ERR(sonypi_device.pdev)) {
-		ret = PTR_ERR(sonypi_device.pdev);
-		goto out_platformdev;
-	}
-
+	sonypi_display_info();
 	sonypi_enable(0);
 
-	printk(KERN_INFO "sonypi: Sony Programmable I/O Controller Driver"
-	       "v%s.\n", SONYPI_DRIVER_VERSION);
-	printk(KERN_INFO "sonypi: detected type%d model, "
-	       "verbose = %d, fnkeyinit = %s, camera = %s, "
-	       "compat = %s, mask = 0x%08lx, useinput = %s, acpi = %s\n",
-	       sonypi_device.model,
-	       verbose,
-	       fnkeyinit ? "on" : "off",
-	       camera ? "on" : "off",
-	       compat ? "on" : "off",
-	       mask,
-	       useinput ? "on" : "off",
-	       SONYPI_ACPI_ACTIVE ? "on" : "off");
-	printk(KERN_INFO "sonypi: enabled at irq=%d, port1=0x%x, port2=0x%x\n",
-	       sonypi_device.irq,
-	       sonypi_device.ioport1, sonypi_device.ioport2);
-
-	if (minor == -1)
-		printk(KERN_INFO "sonypi: device allocated minor is %d\n",
-		       sonypi_misc_device.minor);
-
 	return 0;
 
-out_platformdev:
-	kfifo_free(sonypi_device.input_fifo);
-out_infifo:
+ err_inpdev_unregister:
 	input_unregister_device(sonypi_device.input_key_dev);
 	input_unregister_device(sonypi_device.input_jog_dev);
-out_inputdevices:
+ err_miscdev_unregister:
+	misc_deregister(&sonypi_misc_device);
+ err_free_irq:
 	free_irq(sonypi_device.irq, sonypi_irq);
-out_reqirq:
+ err_free_ioports:
 	release_region(sonypi_device.ioport1, sonypi_device.region_size);
-out_reqreg:
-	misc_deregister(&sonypi_misc_device);
-out_miscreg:
-	if (pcidev)
+ err_disable_pcidev:
+	if (pcidev) {
 		pci_disable_device(pcidev);
-out_pcienable:
+		pci_dev_put(sonypi_device.dev);
+	}
+ err_free_fifo:
 	kfifo_free(sonypi_device.fifo);
-out_fifo:
-	pci_dev_put(sonypi_device.dev);
-	return ret;
+
+	return error;
 }
 
-static void __devexit sonypi_remove(void)
+static int __devexit sonypi_remove(struct platform_device *dev)
 {
 	sonypi_disable();
 
 	synchronize_sched();  /* Allow sonypi interrupt to complete. */
 	flush_scheduled_work();
 
-	platform_device_unregister(sonypi_device.pdev);
-
 	if (useinput) {
 		input_unregister_device(sonypi_device.input_key_dev);
 		input_unregister_device(sonypi_device.input_jog_dev);
 		kfifo_free(sonypi_device.input_fifo);
 	}
 
+	misc_deregister(&sonypi_misc_device);
+
 	free_irq(sonypi_device.irq, sonypi_irq);
 	release_region(sonypi_device.ioport1, sonypi_device.region_size);
-	misc_deregister(&sonypi_misc_device);
-	if (sonypi_device.dev)
+
+	if (sonypi_device.dev) {
 		pci_disable_device(sonypi_device.dev);
+		pci_dev_put(sonypi_device.dev);
+	}
+
 	kfifo_free(sonypi_device.fifo);
-	pci_dev_put(sonypi_device.dev);
-	printk(KERN_INFO "sonypi: removed.\n");
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int old_camera_power;
+
+static int sonypi_suspend(struct platform_device *dev, pm_message_t state)
+{
+	old_camera_power = sonypi_device.camera_power;
+	sonypi_disable();
+
+	return 0;
+}
+
+static int sonypi_resume(struct platform_device *dev)
+{
+	sonypi_enable(old_camera_power);
+	return 0;
 }
+#else
+#define sonypi_suspend	NULL
+#define sonypi_resume	NULL
+#endif
+
+static void sonypi_shutdown(struct platform_device *dev)
+{
+	sonypi_disable();
+}
+
+static struct platform_driver sonypi_driver = {
+	.driver		= {
+		.name	= "sonypi",
+		.owner	= THIS_MODULE,
+	},
+	.probe		= sonypi_probe,
+	.remove		= __devexit_p(sonypi_remove),
+	.shutdown	= sonypi_shutdown,
+	.suspend	= sonypi_suspend,
+	.resume		= sonypi_resume,
+};
+
+static struct platform_device *sonypi_platform_device;
 
 static struct dmi_system_id __initdata sonypi_dmi_table[] = {
 	{
@@ -1451,26 +1485,43 @@ static struct dmi_system_id __initdata s
 
 static int __init sonypi_init(void)
 {
-	int ret;
+	int error;
+
+	printk(KERN_INFO
+		"sonypi: Sony Programmable I/O Controller Driver v%s.\n",
+		SONYPI_DRIVER_VERSION);
 
 	if (!dmi_check_system(sonypi_dmi_table))
 		return -ENODEV;
 
-	ret = platform_driver_register(&sonypi_driver);
-	if (ret)
-		return ret;
+	error = platform_driver_register(&sonypi_driver);
+	if (error)
+		return error;
+
+	sonypi_platform_device = platform_device_alloc("sonypi", -1);
+	if (!sonypi_platform_device) {
+		error = -ENOMEM;
+		goto err_driver_unregister;
+	}
 
-	ret = sonypi_probe();
-	if (ret)
-		platform_driver_unregister(&sonypi_driver);
+	error = platform_device_add(sonypi_platform_device);
+	if (error)
+		goto err_free_device;
 
-	return ret;
+	return 0;
+
+ err_free_device:
+	platform_device_put(sonypi_platform_device);
+ err_driver_unregister:
+	platform_driver_unregister(&sonypi_driver);
+	return error;
 }
 
 static void __exit sonypi_exit(void)
 {
+	platform_device_unregister(sonypi_platform_device);
 	platform_driver_unregister(&sonypi_driver);
-	sonypi_remove();
+	printk(KERN_INFO "sonypi: removed.\n");
 }
 
 module_init(sonypi_init);
#1 lore raw
Quoted 8 lines · Dmitry Torokhov

Hi,

Now that we allow manual binding and unbinding devices through sysfs it is better if main device initialization is done in ->probe() instead of module_init(). The following patch converts sonypi driver to this model.

The patch compiles but I was unable to test it since I don't have the hardware...

[...]

Review

Quoted 6 lines
(quoted diff) +6 -0
+static int __devinit sonypi_setup_irq(struct sonypi_device *dev,
+				      const struct sonypi_irq_list *irq_list)
+{
+	while (irq_list->irq) {
+
+		if (!request_irq(dev->irq, sonypi_irq,
                                 ^^^^^^^^

this should be irq_list->irq

other than that seems to work here on a type2 model:

sonypi: Sony Programmable I/O Controller Driver v1.26.
sonypi: trying irq 11
input: Sony Vaio Jogdial as /class/input/input8
input: Sony Vaio Keys as /class/input/input9
sonypi: detected type2 model, verbose = 1, fnkeyinit = off, camera = off, compat = off, mask = 0xffffffff, useinput = on, acpi = on
sonypi: enabled at irq=11, port1=0x1080, port2=0x1084
sonypi: device allocated minor is 63
sonypi: unknown event port1=0x0f,port2=0x05

Oh, there seems to be a spurious interrupt happening at modules insertion (I suspect sonypi_enable triggering and ignoring it), but this happens with the old module too and I never noticed it before. Wouldn't make more sense to print the warning even if verbose=0 to be able to catch it timely? I mean it's since 2.4 times I don't enable verbose mode in sonypi...

Signature · 2 lines
mattia
:wq!
#2 lore raw
Quoted 21 lines · Mattia Dongili
Quoted 8 lines · Dmitry Torokhov

Hi,

Now that we allow manual binding and unbinding devices through sysfs it is better if main device initialization is done in ->probe() instead of module_init(). The following patch converts sonypi driver to this model.

The patch compiles but I was unable to test it since I don't have the hardware...

[...]

Review

Quoted 6 lines
(quoted diff) +6 -0
+static int __devinit sonypi_setup_irq(struct sonypi_device *dev,
+                                   const struct sonypi_irq_list *irq_list)
+{
+     while (irq_list->irq) {
+
+             if (!request_irq(dev->irq, sonypi_irq,
                                ^^^^^^^^

this should be irq_list->irq

other than that seems to work here on a type2 model:

Quoted 9 lines

sonypi: Sony Programmable I/O Controller Driver v1.26.
sonypi: trying irq 11
input: Sony Vaio Jogdial as /class/input/input8
input: Sony Vaio Keys as /class/input/input9
sonypi: detected type2 model, verbose = 1, fnkeyinit = off, camera = off, compat = off, mask = 0xffffffff, useinput = on, acpi = on
sonypi: enabled at irq=11, port1=0x1080, port2=0x1084
sonypi: device allocated minor is 63
sonypi: unknown event port1=0x0f,port2=0x05

Thank you very much for testing and debugging the patch. I will fix the irq thing and repost.

Quoted 7 lines

Oh, there seems to be a spurious interrupt happening at modules insertion (I suspect sonypi_enable triggering and ignoring it), but this happens with the old module too and I never noticed it before. Wouldn't make more sense to print the warning even if verbose=0 to be able to catch it timely? I mean it's since 2.4 times I don't enable verbose mode in sonypi...

Probably, let's see what Stelian will say.

--
Dmitry

#3 lore raw

sonypi searching new maintainer (Was: Re: [RFT] Sonypi: convert to the new platform device interface)

Quoted 5 lines · Dmitry Torokhov

On 12/13/05, Mattia Dongili <[email protected]> wrote:

                           ^^^^^^^^
Quoted 3 lines

this should be irq_list->irq

other than that seems to work here on a type2 model:

Thanks you very much for testing Mattia. Oh, and thanks to you too Dmitry for your continuous maintenance :)

This is probably an appropriate moment to announce my resignation from the sonypi maintainership.

After five years, I found myself less and less interested in working on this driver, and more and more frustrated by the Sony complete lack of support. They ignored all the requests for documentation I and several others made, both from outside and from inside Sony. They also keep changing the hardware interfaces, so it has become increasingly difficult to support the newer Vaios in sonypi.

At this point, I wouldn't recommend anyone buying a Sony laptop. Other manufacturers are more Linux-friendly and overall their laptops are much better supported under Linux than the Sony's.

I already did the switch myself a few months ago, buying an Apple Powerbook, and today I am very glad I did.

I am still answering to the sonypi related questions for the time being but if someone is interested in taking over, just contact me. Otherwise, I will submit a patch marking the driver as unmaintained in a few days.

The meye driver (MotionEye camera for the PictureBook C1 series) is also going the same path, but since the hardware is not produced anymore (and hasn't been for a long time now), I don't expect it to find another maintainer.

Quoted 1 line
Quoted 1 line

sonypi: unknown event port1=0x0f,port2=0x05

[...]

Quoted 8 lines
Quoted 7 lines

Oh, there seems to be a spurious interrupt happening at modules insertion (I suspect sonypi_enable triggering and ignoring it), but this happens with the old module too and I never noticed it before. Wouldn't make more sense to print the warning even if verbose=0 to be able to catch it timely? I mean it's since 2.4 times I don't enable verbose mode in sonypi...

Probably, let's see what Stelian will say.

This is the "ok I'm loaded" event. I am not sure this event is available on all the sonypi supported platforms, that's why it hasn't been defined as a known event. And it doesn't make much sense to forward it anyways.

I would leave it like it is now.

Stelian.

Signature · 1 line
Stelian Pop <[email protected]>
#4 lore raw

Re: sonypi searching new maintainer (Was: Re: [RFT] Sonypi: convert to the new platform device interface)

Quoted 10 lines · Stelian Pop

Le mardi 13 décembre 2005 à 14:04 -0500, Dmitry Torokhov a >

Quoted 1 line
Quoted 1 line

sonypi: unknown event port1=0x0f,port2=0x05

[...]

Quoted 7 lines
Quoted 7 lines

Oh, there seems to be a spurious interrupt happening at modules insertion (I suspect sonypi_enable triggering and ignoring it), but this happens with the old module too and I never noticed it before. Wouldn't make more sense to print the warning even if verbose=0 to be able to catch it timely? I mean it's since 2.4 times I don't enable verbose mode in sonypi...

Quoted 8 lines
Quoted 1 line

Probably, let's see what Stelian will say.

This is the "ok I'm loaded" event. I am not sure this event is available on all the sonypi supported platforms, that's why it hasn't been defined as a known event. And it doesn't make much sense to forward it anyways.

I would leave it like it is now.

But when it is reported is it the same event? If so we could just not warn when we see it (but still dont forward it to the userspace).

--
Dmitry

#5 lore raw

Re: sonypi searching new maintainer (Was: Re: [RFT] Sonypi: convert to the new platform device interface)

Quoted 13 lines · Dmitry Torokhov
Quoted 12 lines · Stelian Pop

Le mardi 13 décembre 2005 à 14:04 -0500, Dmitry Torokhov a >

Quoted 1 line
Quoted 1 line

sonypi: unknown event port1=0x0f,port2=0x05

[...]

Quoted 8 lines
Quoted 7 lines

Oh, there seems to be a spurious interrupt happening at modules insertion (I suspect sonypi_enable triggering and ignoring it), but this happens with the old module too and I never noticed it before. Wouldn't make more sense to print the warning even if verbose=0 to be able to catch it timely? I mean it's since 2.4 times I don't enable verbose mode in sonypi...

Probably, let's see what Stelian will say.

Quoted 8 lines
Quoted 6 lines

This is the "ok I'm loaded" event. I am not sure this event is available on all the sonypi supported platforms, that's why it hasn't been defined as a known event. And it doesn't make much sense to forward it anyways.

I would leave it like it is now.

But when it is reported is it the same event?

I don't follow you here...

Quoted 2 lines

If so we could just not
warn when we see it (but still dont forward it to the userspace).

The warning is only present if 'verbose > 0', so in normal conditions you won't see it.

Stelian.

Signature · 1 line
Stelian Pop <[email protected]>
#6 lore raw

Re: sonypi searching new maintainer (Was: Re: [RFT] Sonypi: convert to the new platform device interface)

Quoted 18 lines · Stelian Pop
Quoted 17 lines · Dmitry Torokhov
Quoted 16 lines · Stelian Pop

Le mardi 13 décembre 2005 à 14:04 -0500, Dmitry Torokhov a >

Quoted 1 line
Quoted 1 line

sonypi: unknown event port1=0x0f,port2=0x05

[...]

Quoted 8 lines
Quoted 7 lines

Oh, there seems to be a spurious interrupt happening at modules insertion (I suspect sonypi_enable triggering and ignoring it), but this happens with the old module too and I never noticed it before. Wouldn't make more sense to print the warning even if verbose=0 to be able to catch it timely? I mean it's since 2.4 times I don't enable verbose mode in sonypi...

Probably, let's see what Stelian will say.

This is the "ok I'm loaded" event. I am not sure this event is available on all the sonypi supported platforms, that's why it hasn't been defined as a known event. And it doesn't make much sense to forward it anyways.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I would leave it like it is now.

But when it is reported is it the same event?

I don't follow you here...

I was talking about that "ok, i'm loaded" event. When it is reported is it the same v1,v2 pair all the time? If it is the same we could suppress "unknown" message in verbose mode.

--
Dmitry

#7 lore raw

Re: sonypi searching new maintainer (Was: Re: [RFT] Sonypi: convert to the new platform device interface)

Quoted 22 lines · Dmitry Torokhov
Quoted 21 lines · Stelian Pop
Quoted 20 lines · Dmitry Torokhov
Quoted 18 lines · Stelian Pop

Le mardi 13 décembre 2005 à 14:04 -0500, Dmitry Torokhov a >

Quoted 1 line
Quoted 1 line

sonypi: unknown event port1=0x0f,port2=0x05

[...]

Quoted 8 lines
Quoted 7 lines

Oh, there seems to be a spurious interrupt happening at modules insertion (I suspect sonypi_enable triggering and ignoring it), but this happens with the old module too and I never noticed it before. Wouldn't make more sense to print the warning even if verbose=0 to be able to catch it timely? I mean it's since 2.4 times I don't enable verbose mode in sonypi...

Probably, let's see what Stelian will say.

This is the "ok I'm loaded" event. I am not sure this event is available on all the sonypi supported platforms, that's why it hasn't been defined as a known event. And it doesn't make much sense to forward it anyways.

I would leave it like it is now.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

But when it is reported is it the same event?

I don't follow you here...

I was talking about that "ok, i'm loaded" event. When it is reported is it the same v1,v2 pair all the time?

I have no idea. That's one of the problems with the sonypi events:
different laptops behave differently, and sometimes Sony even changes the meaning of some events...

Quoted 2 lines

If it is the same we could
suppress "unknown" message in verbose mode.

Why would you want to suppress a message in verbose mode ? The verbose option is there exactly for that: show the user all the data coming from the hardware, and depending on the verbose value only show the data which hasn't been decoded, or all of it.

I don't think that adding a special hack for this event in an already hacky driver has some added value.

Stelian.

Signature · 1 line
Stelian Pop <[email protected]>
#8 lore raw
In reply to Dmitry Torokhov
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

The patch compiles but I was unable to test it since I don't have the hardware...

other than that seems to work here on a type2 model:

It does not work here on a SONY VAIO U3. After loading the sonypi module, neither mev nor showkey return something for the special stuff like jogwheel, jogbutton or Fn keys respectively.

Running 2.6.15-rc7, this appeared in the kernel log:

Dec 25 22:06:14 takeshi kernel: sonypi: request_irq failed

Jan Engelhardt

Signature · 2 lines
| Alphagate Systems, http://alphagate.hopto.org/
| jengelh's site, http://jengelh.hopto.org/
#9 lore raw
Quoted 4 lines · Jan Engelhardt
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

The patch compiles but I was unable to test it since I don't have the hardware...

Quoted 9 lines
Quoted 1 line
Quoted 1 line

other than that seems to work here on a type2 model:

It does not work here on a SONY VAIO U3. After loading the sonypi module, neither mev nor showkey return something for the special stuff like jogwheel, jogbutton or Fn keys respectively.

Running 2.6.15-rc7, this appeared in the kernel log:

Dec 25 22:06:14 takeshi kernel: sonypi: request_irq failed

Jan,

You did make the changes Maattia Dongili was talking about, didn't you? Just in case I am sending corrected patch.

Signature · 507 lines
Dmitry

Sonypi: convert to the new platform device interface

Do not use platform_device_register_simple() as it is going away,
implement ->probe() and ->remove() functions so manual binding and
unbinding will work with this driver.

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

 drivers/char/sonypi.c |  358 ++++++++++++++++++++++++++++----------------------
 1 files changed, 206 insertions(+), 152 deletions(-)

Index: work/drivers/char/sonypi.c
===================================================================
--- work.orig/drivers/char/sonypi.c
+++ work/drivers/char/sonypi.c
@@ -471,7 +471,6 @@ struct sonypi_keypress {
 
 static struct sonypi_device {
 	struct pci_dev *dev;
-	struct platform_device *pdev;
 	u16 irq;
 	u16 bits;
 	u16 ioport1;
@@ -1165,45 +1164,12 @@ static int sonypi_disable(void)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int old_camera_power;
-
-static int sonypi_suspend(struct platform_device *dev, pm_message_t state)
-{
-	old_camera_power = sonypi_device.camera_power;
-	sonypi_disable();
-
-	return 0;
-}
-
-static int sonypi_resume(struct platform_device *dev)
-{
-	sonypi_enable(old_camera_power);
-	return 0;
-}
-#endif
-
-static void sonypi_shutdown(struct platform_device *dev)
-{
-	sonypi_disable();
-}
-
-static struct platform_driver sonypi_driver = {
-#ifdef CONFIG_PM
-	.suspend	= sonypi_suspend,
-	.resume		= sonypi_resume,
-#endif
-	.shutdown	= sonypi_shutdown,
-	.driver		= {
-		.name	= "sonypi",
-	},
-};
-
 static int __devinit sonypi_create_input_devices(void)
 {
 	struct input_dev *jog_dev;
 	struct input_dev *key_dev;
 	int i;
+	int error;
 
 	sonypi_device.input_jog_dev = jog_dev = input_allocate_device();
 	if (!jog_dev)
@@ -1219,9 +1185,8 @@ static int __devinit sonypi_create_input
 
 	sonypi_device.input_key_dev = key_dev = input_allocate_device();
 	if (!key_dev) {
-		input_free_device(jog_dev);
-		sonypi_device.input_jog_dev = NULL;
-		return -ENOMEM;
+		error = -ENOMEM;
+		goto err_free_jogdev;
 	}
 
 	key_dev->name = "Sony Vaio Keys";
@@ -1234,56 +1199,122 @@ static int __devinit sonypi_create_input
 		if (sonypi_inputkeys[i].inputev)
 			set_bit(sonypi_inputkeys[i].inputev, key_dev->keybit);
 
-	input_register_device(jog_dev);
-	input_register_device(key_dev);
+	error = input_register_device(jog_dev);
+	if (error)
+		goto err_free_keydev;
+
+	error = input_register_device(key_dev);
+	if (error)
+		goto err_unregister_jogdev;
 
 	return 0;
+
+ err_unregister_jogdev:
+	input_unregister_device(jog_dev);
+	/* Set to NULL so we don't free it again below */
+	jog_dev = NULL;
+ err_free_keydev:
+	input_free_device(key_dev);
+	sonypi_device.input_key_dev = NULL;
+ err_free_jogdev:
+	input_free_device(jog_dev);
+	sonypi_device.input_jog_dev = NULL;
+
+	return error;
 }
 
-static int __devinit sonypi_probe(void)
+static int __devinit sonypi_setup_ioports(struct sonypi_device *dev,
+				const struct sonypi_ioport_list *ioport_list)
 {
-	int i, ret;
-	struct sonypi_ioport_list *ioport_list;
-	struct sonypi_irq_list *irq_list;
-	struct pci_dev *pcidev;
+	while (ioport_list->port1) {
 
-	if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
-				     PCI_DEVICE_ID_INTEL_82371AB_3, NULL)))
-		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE1;
-	else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
-					  PCI_DEVICE_ID_INTEL_ICH6_1, NULL)))
-		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE3;
-	else
-		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE2;
+		if (request_region(ioport_list->port1,
+				   sonypi_device.region_size,
+				   "Sony Programable I/O Device")) {
+			dev->ioport1 = ioport_list->port1;
+			dev->ioport2 = ioport_list->port2;
+			return 0;
+		}
+		ioport_list++;
+	}
 
-	sonypi_device.dev = pcidev;
+	return -EBUSY;
+}
+
+static int __devinit sonypi_setup_irq(struct sonypi_device *dev,
+				      const struct sonypi_irq_list *irq_list)
+{
+	while (irq_list->irq) {
+
+		if (!request_irq(irq_list->irq, sonypi_irq,
+				 SA_SHIRQ, "sonypi", sonypi_irq)) {
+			dev->irq = irq_list->irq;
+			dev->bits = irq_list->bits;
+			return 0;
+		}
+		irq_list++;
+	}
+
+	return -EBUSY;
+}
+
+static void __devinit sonypi_display_info(void)
+{
+	printk(KERN_INFO "sonypi: detected type%d model, "
+	       "verbose = %d, fnkeyinit = %s, camera = %s, "
+	       "compat = %s, mask = 0x%08lx, useinput = %s, acpi = %s\n",
+	       sonypi_device.model,
+	       verbose,
+	       fnkeyinit ? "on" : "off",
+	       camera ? "on" : "off",
+	       compat ? "on" : "off",
+	       mask,
+	       useinput ? "on" : "off",
+	       SONYPI_ACPI_ACTIVE ? "on" : "off");
+	printk(KERN_INFO "sonypi: enabled at irq=%d, port1=0x%x, port2=0x%x\n",
+	       sonypi_device.irq,
+	       sonypi_device.ioport1, sonypi_device.ioport2);
+
+	if (minor == -1)
+		printk(KERN_INFO "sonypi: device allocated minor is %d\n",
+		       sonypi_misc_device.minor);
+}
+
+static int __devinit sonypi_probe(struct platform_device *dev)
+{
+	const struct sonypi_ioport_list *ioport_list;
+	const struct sonypi_irq_list *irq_list;
+	struct pci_dev *pcidev;
+	int error;
 
 	spin_lock_init(&sonypi_device.fifo_lock);
 	sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
 					 &sonypi_device.fifo_lock);
 	if (IS_ERR(sonypi_device.fifo)) {
 		printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
-		ret = PTR_ERR(sonypi_device.fifo);
-		goto out_fifo;
+		return PTR_ERR(sonypi_device.fifo);
 	}
 
 	init_waitqueue_head(&sonypi_device.fifo_proc_list);
 	init_MUTEX(&sonypi_device.lock);
 	sonypi_device.bluetooth_power = -1;
 
+	if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
+				     PCI_DEVICE_ID_INTEL_82371AB_3, NULL)))
+		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE1;
+	else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
+					  PCI_DEVICE_ID_INTEL_ICH6_1, NULL)))
+		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE3;
+	else
+		sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE2;
+
 	if (pcidev && pci_enable_device(pcidev)) {
 		printk(KERN_ERR "sonypi: pci_enable_device failed\n");
-		ret = -EIO;
-		goto out_pcienable;
-	}
-
-	if (minor != -1)
-		sonypi_misc_device.minor = minor;
-	if ((ret = misc_register(&sonypi_misc_device))) {
-		printk(KERN_ERR "sonypi: misc_register failed\n");
-		goto out_miscreg;
+		error = -EIO;
+		goto err_put_pcidev;
 	}
 
+	sonypi_device.dev = pcidev;
 
 	if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE1) {
 		ioport_list = sonypi_type1_ioport_list;
@@ -1302,43 +1333,36 @@ static int __devinit sonypi_probe(void)
 		irq_list = sonypi_type3_irq_list;
 	}
 
-	for (i = 0; ioport_list[i].port1; i++) {
-		if (request_region(ioport_list[i].port1,
-				   sonypi_device.region_size,
-				   "Sony Programable I/O Device")) {
-			/* get the ioport */
-			sonypi_device.ioport1 = ioport_list[i].port1;
-			sonypi_device.ioport2 = ioport_list[i].port2;
-			break;
-		}
-	}
-	if (!sonypi_device.ioport1) {
-		printk(KERN_ERR "sonypi: request_region failed\n");
-		ret = -ENODEV;
-		goto out_reqreg;
+	error = sonypi_setup_ioports(&sonypi_device, ioport_list);
+	if (error) {
+		printk(KERN_ERR "sonypi: failed to request ioports\n");
+		goto err_disable_pcidev;
 	}
 
-	for (i = 0; irq_list[i].irq; i++) {
-
-		sonypi_device.irq = irq_list[i].irq;
-		sonypi_device.bits = irq_list[i].bits;
-
-		if (!request_irq(sonypi_device.irq, sonypi_irq,
-				 SA_SHIRQ, "sonypi", sonypi_irq))
-			break;
+	error = sonypi_setup_irq(&sonypi_device, irq_list);
+	if (error) {
+		printk(KERN_ERR "sonypi: request_irq failed\n");
+		goto err_free_ioports;
 	}
 
-	if (!irq_list[i].irq) {
-		printk(KERN_ERR "sonypi: request_irq failed\n");
-		ret = -ENODEV;
-		goto out_reqirq;
+	if (minor != -1)
+		sonypi_misc_device.minor = minor;
+	error = misc_register(&sonypi_misc_device);
+	if (error) {
+		printk(KERN_ERR "sonypi: misc_register failed\n");
+		goto err_free_irq;
 	}
 
+	sonypi_display_info();
+
 	if (useinput) {
 
-		ret = sonypi_create_input_devices();
-		if (ret)
-			goto out_inputdevices;
+		error = sonypi_create_input_devices();
+		if (error) {
+			printk(KERN_ERR
+				"sonypi: failed to create input devices\n");
+			goto err_miscdev_unregister;
+		}
 
 		spin_lock_init(&sonypi_device.input_fifo_lock);
 		sonypi_device.input_fifo =
@@ -1346,90 +1370,103 @@ static int __devinit sonypi_probe(void)
 				    &sonypi_device.input_fifo_lock);
 		if (IS_ERR(sonypi_device.input_fifo)) {
 			printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
-			ret = PTR_ERR(sonypi_device.input_fifo);
-			goto out_infifo;
+			error = PTR_ERR(sonypi_device.input_fifo);
+			goto err_inpdev_unregister;
 		}
 
 		INIT_WORK(&sonypi_device.input_work, input_keyrelease, NULL);
 	}
 
-	sonypi_device.pdev = platform_device_register_simple("sonypi", -1,
-							     NULL, 0);
-	if (IS_ERR(sonypi_device.pdev)) {
-		ret = PTR_ERR(sonypi_device.pdev);
-		goto out_platformdev;
-	}
-
 	sonypi_enable(0);
 
-	printk(KERN_INFO "sonypi: Sony Programmable I/O Controller Driver"
-	       "v%s.\n", SONYPI_DRIVER_VERSION);
-	printk(KERN_INFO "sonypi: detected type%d model, "
-	       "verbose = %d, fnkeyinit = %s, camera = %s, "
-	       "compat = %s, mask = 0x%08lx, useinput = %s, acpi = %s\n",
-	       sonypi_device.model,
-	       verbose,
-	       fnkeyinit ? "on" : "off",
-	       camera ? "on" : "off",
-	       compat ? "on" : "off",
-	       mask,
-	       useinput ? "on" : "off",
-	       SONYPI_ACPI_ACTIVE ? "on" : "off");
-	printk(KERN_INFO "sonypi: enabled at irq=%d, port1=0x%x, port2=0x%x\n",
-	       sonypi_device.irq,
-	       sonypi_device.ioport1, sonypi_device.ioport2);
-
-	if (minor == -1)
-		printk(KERN_INFO "sonypi: device allocated minor is %d\n",
-		       sonypi_misc_device.minor);
-
 	return 0;
 
-out_platformdev:
-	kfifo_free(sonypi_device.input_fifo);
-out_infifo:
+ err_inpdev_unregister:
 	input_unregister_device(sonypi_device.input_key_dev);
 	input_unregister_device(sonypi_device.input_jog_dev);
-out_inputdevices:
+ err_miscdev_unregister:
+	misc_deregister(&sonypi_misc_device);
+ err_free_irq:
 	free_irq(sonypi_device.irq, sonypi_irq);
-out_reqirq:
+ err_free_ioports:
 	release_region(sonypi_device.ioport1, sonypi_device.region_size);
-out_reqreg:
-	misc_deregister(&sonypi_misc_device);
-out_miscreg:
+ err_disable_pcidev:
 	if (pcidev)
 		pci_disable_device(pcidev);
-out_pcienable:
+ err_put_pcidev:
+	pci_dev_put(pcidev);
 	kfifo_free(sonypi_device.fifo);
-out_fifo:
-	pci_dev_put(sonypi_device.dev);
-	return ret;
+
+	return error;
 }
 
-static void __devexit sonypi_remove(void)
+static int __devexit sonypi_remove(struct platform_device *dev)
 {
 	sonypi_disable();
 
 	synchronize_sched();  /* Allow sonypi interrupt to complete. */
 	flush_scheduled_work();
 
-	platform_device_unregister(sonypi_device.pdev);
-
 	if (useinput) {
 		input_unregister_device(sonypi_device.input_key_dev);
 		input_unregister_device(sonypi_device.input_jog_dev);
 		kfifo_free(sonypi_device.input_fifo);
 	}
 
+	misc_deregister(&sonypi_misc_device);
+
 	free_irq(sonypi_device.irq, sonypi_irq);
 	release_region(sonypi_device.ioport1, sonypi_device.region_size);
-	misc_deregister(&sonypi_misc_device);
-	if (sonypi_device.dev)
+
+	if (sonypi_device.dev) {
 		pci_disable_device(sonypi_device.dev);
+		pci_dev_put(sonypi_device.dev);
+	}
+
 	kfifo_free(sonypi_device.fifo);
-	pci_dev_put(sonypi_device.dev);
-	printk(KERN_INFO "sonypi: removed.\n");
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int old_camera_power;
+
+static int sonypi_suspend(struct platform_device *dev, pm_message_t state)
+{
+	old_camera_power = sonypi_device.camera_power;
+	sonypi_disable();
+
+	return 0;
+}
+
+static int sonypi_resume(struct platform_device *dev)
+{
+	sonypi_enable(old_camera_power);
+	return 0;
 }
+#else
+#define sonypi_suspend	NULL
+#define sonypi_resume	NULL
+#endif
+
+static void sonypi_shutdown(struct platform_device *dev)
+{
+	sonypi_disable();
+}
+
+static struct platform_driver sonypi_driver = {
+	.driver		= {
+		.name	= "sonypi",
+		.owner	= THIS_MODULE,
+	},
+	.probe		= sonypi_probe,
+	.remove		= __devexit_p(sonypi_remove),
+	.shutdown	= sonypi_shutdown,
+	.suspend	= sonypi_suspend,
+	.resume		= sonypi_resume,
+};
+
+static struct platform_device *sonypi_platform_device;
 
 static struct dmi_system_id __initdata sonypi_dmi_table[] = {
 	{
@@ -1451,26 +1488,43 @@ static struct dmi_system_id __initdata s
 
 static int __init sonypi_init(void)
 {
-	int ret;
+	int error;
+
+	printk(KERN_INFO
+		"sonypi: Sony Programmable I/O Controller Driver v%s.\n",
+		SONYPI_DRIVER_VERSION);
 
 	if (!dmi_check_system(sonypi_dmi_table))
 		return -ENODEV;
 
-	ret = platform_driver_register(&sonypi_driver);
-	if (ret)
-		return ret;
+	error = platform_driver_register(&sonypi_driver);
+	if (error)
+		return error;
+
+	sonypi_platform_device = platform_device_alloc("sonypi", -1);
+	if (!sonypi_platform_device) {
+		error = -ENOMEM;
+		goto err_driver_unregister;
+	}
 
-	ret = sonypi_probe();
-	if (ret)
-		platform_driver_unregister(&sonypi_driver);
+	error = platform_device_add(sonypi_platform_device);
+	if (error)
+		goto err_free_device;
 
-	return ret;
+	return 0;
+
+ err_free_device:
+	platform_device_put(sonypi_platform_device);
+ err_driver_unregister:
+	platform_driver_unregister(&sonypi_driver);
+	return error;
 }
 
 static void __exit sonypi_exit(void)
 {
+	platform_device_unregister(sonypi_platform_device);
 	platform_driver_unregister(&sonypi_driver);
-	sonypi_remove();
+	printk(KERN_INFO "sonypi: removed.\n");
 }
 
 module_init(sonypi_init);
#10 lore raw
Quoted 9 lines
Quoted 6 lines

It does not work here on a SONY VAIO U3. After loading the sonypi module, neither mev nor showkey return something for the special stuff like jogwheel, jogbutton or Fn keys respectively.

Running 2.6.15-rc7, this appeared in the kernel log:

Dec 25 22:06:14 takeshi kernel: sonypi: request_irq failed

Just in case I am sending corrected patch.

Ok now it works. (Just like with the old sonypi :-)

However, there are some things that remain unresolved:
- the "mousewheel" reports only once every 2 seconds when constantly wheeling (in mev)
- pressing the jogdial button produces a keyboard event (keycode 158) rather than a mousebutton 3 event

BTW, how can I use the Fn keys on console (keycodes 466-477) for arbitrary shell commands?
Such a feature, among which special combinations like Ctrl+Alt+Del also belong, are handled by the kernel which leaves almost no room for user-defined userspace action. Any idea?

Jan Engelhardt

Signature · 2 lines
| Alphagate Systems, http://alphagate.hopto.org/
| jengelh's site, http://jengelh.hopto.org/
#11 lore raw
Quoted 11 lines · Jan Engelhardt
Quoted 9 lines
Quoted 6 lines

It does not work here on a SONY VAIO U3. After loading the sonypi module, neither mev nor showkey return something for the special stuff like jogwheel, jogbutton or Fn keys respectively.

Running 2.6.15-rc7, this appeared in the kernel log:

Dec 25 22:06:14 takeshi kernel: sonypi: request_irq failed

Just in case I am sending corrected patch.

Ok now it works. (Just like with the old sonypi :-)

The issues enumerated below are existed before my patch, did I understand this correctly?

Quoted 6 lines

However, there are some things that remain unresolved:
- the "mousewheel" reports only once every 2 seconds when constantly wheeling (in mev)
- pressing the jogdial button produces a keyboard event (keycode 158) rather than a mousebutton 3 event

158 is KEY_BACK and is generated on type2 models.. If you load the driver with verbose=1 what does it say when you press jog dial?

Quoted 6 lines

BTW, how can I use the Fn keys on console (keycodes 466-477) for arbitrary shell commands?
Such a feature, among which special combinations like Ctrl+Alt+Del also belong, are handled by the kernel which leaves almost no room for user-defined userspace action. Any idea?

There are daemons that read corersponding /dev/input/eventX and act on it. The in-kernel keyboard driver ignores keycodes above 255.

--
Dmitry

#12 lore raw
Quoted 3 lines · Dmitry Torokhov
Quoted 3 lines

However, there are some things that remain unresolved:
- the "mousewheel" reports only once every 2 seconds when constantly wheeling (in mev)

could be because scrolling the wheel generates several kinds of events (up, down but also fast up, fast down etc), and only some of them get interpreted. Verify the events by using the verbose=1 parameter.

Quoted 5 lines
Quoted 3 lines

- pressing the jogdial button produces a keyboard event (keycode 158) rather than a mousebutton 3 event

158 is KEY_BACK and is generated on type2 models.. If you load the driver with verbose=1 what does it say when you press jog dial?

If you don't have a Back button then you can adjust the 'mask' module parameter in order to detect only the events you are interested in. And before you ask yes, Sony reused the same codes for several types of events...

Quoted 8 lines
Quoted 6 lines

BTW, how can I use the Fn keys on console (keycodes 466-477) for arbitrary shell commands?
Such a feature, among which special combinations like Ctrl+Alt+Del also belong, are handled by the kernel which leaves almost no room for user-defined userspace action. Any idea?

There are daemons that read corersponding /dev/input/eventX and act on it. The in-kernel keyboard driver ignores keycodes above 255.

And also daemons more sonypi specific which read /dev/sonypi instead, like sonypid, sonypidd, jogdiald, kde etc.

Stelian.

Signature · 1 line
Stelian Pop <[email protected]>
#13 lore raw
Quoted 1 line · Stelian Pop

[sonypi3]

When is this going to be merged?

Jan Engelhardt

#14 lore raw
Quoted 8 lines · Jan Engelhardt
Quoted 1 line · Stelian Pop

[sonypi3]

When is this going to be merged?

It's in Linus's tree.

Signature · 1 line
Dmitry