aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/sonypi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/sonypi.c')
-rw-r--r--drivers/char/sonypi.c106
1 files changed, 59 insertions, 47 deletions
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 36ae9ad2598c..f86c15587238 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -424,10 +424,6 @@ static struct sonypi_eventtypes {
424 424
425#define SONYPI_BUF_SIZE 128 425#define SONYPI_BUF_SIZE 128
426 426
427/* The name of the devices for the input device drivers */
428#define SONYPI_JOG_INPUTNAME "Sony Vaio Jogdial"
429#define SONYPI_KEY_INPUTNAME "Sony Vaio Keys"
430
431/* Correspondance table between sonypi events and input layer events */ 427/* Correspondance table between sonypi events and input layer events */
432static struct { 428static struct {
433 int sonypiev; 429 int sonypiev;
@@ -490,8 +486,8 @@ static struct sonypi_device {
490 struct fasync_struct *fifo_async; 486 struct fasync_struct *fifo_async;
491 int open_count; 487 int open_count;
492 int model; 488 int model;
493 struct input_dev input_jog_dev; 489 struct input_dev *input_jog_dev;
494 struct input_dev input_key_dev; 490 struct input_dev *input_key_dev;
495 struct work_struct input_work; 491 struct work_struct input_work;
496 struct kfifo *input_fifo; 492 struct kfifo *input_fifo;
497 spinlock_t input_fifo_lock; 493 spinlock_t input_fifo_lock;
@@ -779,8 +775,8 @@ static void input_keyrelease(void *data)
779 775
780static void sonypi_report_input_event(u8 event) 776static void sonypi_report_input_event(u8 event)
781{ 777{
782 struct input_dev *jog_dev = &sonypi_device.input_jog_dev; 778 struct input_dev *jog_dev = sonypi_device.input_jog_dev;
783 struct input_dev *key_dev = &sonypi_device.input_key_dev; 779 struct input_dev *key_dev = sonypi_device.input_key_dev;
784 struct sonypi_keypress kp = { NULL }; 780 struct sonypi_keypress kp = { NULL };
785 int i; 781 int i;
786 782
@@ -1171,19 +1167,17 @@ static int sonypi_disable(void)
1171#ifdef CONFIG_PM 1167#ifdef CONFIG_PM
1172static int old_camera_power; 1168static int old_camera_power;
1173 1169
1174static int sonypi_suspend(struct device *dev, pm_message_t state, u32 level) 1170static int sonypi_suspend(struct device *dev, pm_message_t state)
1175{ 1171{
1176 if (level == SUSPEND_DISABLE) { 1172 old_camera_power = sonypi_device.camera_power;
1177 old_camera_power = sonypi_device.camera_power; 1173 sonypi_disable();
1178 sonypi_disable(); 1174
1179 }
1180 return 0; 1175 return 0;
1181} 1176}
1182 1177
1183static int sonypi_resume(struct device *dev, u32 level) 1178static int sonypi_resume(struct device *dev)
1184{ 1179{
1185 if (level == RESUME_ENABLE) 1180 sonypi_enable(old_camera_power);
1186 sonypi_enable(old_camera_power);
1187 return 0; 1181 return 0;
1188} 1182}
1189#endif 1183#endif
@@ -1203,6 +1197,47 @@ static struct device_driver sonypi_driver = {
1203 .shutdown = sonypi_shutdown, 1197 .shutdown = sonypi_shutdown,
1204}; 1198};
1205 1199
1200static int __devinit sonypi_create_input_devices(void)
1201{
1202 struct input_dev *jog_dev;
1203 struct input_dev *key_dev;
1204 int i;
1205
1206 sonypi_device.input_jog_dev = jog_dev = input_allocate_device();
1207 if (!jog_dev)
1208 return -ENOMEM;
1209
1210 jog_dev->name = "Sony Vaio Jogdial";
1211 jog_dev->id.bustype = BUS_ISA;
1212 jog_dev->id.vendor = PCI_VENDOR_ID_SONY;
1213
1214 jog_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
1215 jog_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_MIDDLE);
1216 jog_dev->relbit[0] = BIT(REL_WHEEL);
1217
1218 sonypi_device.input_key_dev = key_dev = input_allocate_device();
1219 if (!key_dev) {
1220 input_free_device(jog_dev);
1221 sonypi_device.input_jog_dev = NULL;
1222 return -ENOMEM;
1223 }
1224
1225 key_dev->name = "Sony Vaio Keys";
1226 key_dev->id.bustype = BUS_ISA;
1227 key_dev->id.vendor = PCI_VENDOR_ID_SONY;
1228
1229 /* Initialize the Input Drivers: special keys */
1230 key_dev->evbit[0] = BIT(EV_KEY);
1231 for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
1232 if (sonypi_inputkeys[i].inputev)
1233 set_bit(sonypi_inputkeys[i].inputev, key_dev->keybit);
1234
1235 input_register_device(jog_dev);
1236 input_register_device(key_dev);
1237
1238 return 0;
1239}
1240
1206static int __devinit sonypi_probe(void) 1241static int __devinit sonypi_probe(void)
1207{ 1242{
1208 int i, ret; 1243 int i, ret;
@@ -1298,34 +1333,10 @@ static int __devinit sonypi_probe(void)
1298 } 1333 }
1299 1334
1300 if (useinput) { 1335 if (useinput) {
1301 /* Initialize the Input Drivers: jogdial */
1302 int i;
1303 sonypi_device.input_jog_dev.evbit[0] =
1304 BIT(EV_KEY) | BIT(EV_REL);
1305 sonypi_device.input_jog_dev.keybit[LONG(BTN_MOUSE)] =
1306 BIT(BTN_MIDDLE);
1307 sonypi_device.input_jog_dev.relbit[0] = BIT(REL_WHEEL);
1308 sonypi_device.input_jog_dev.name = SONYPI_JOG_INPUTNAME;
1309 sonypi_device.input_jog_dev.id.bustype = BUS_ISA;
1310 sonypi_device.input_jog_dev.id.vendor = PCI_VENDOR_ID_SONY;
1311
1312 input_register_device(&sonypi_device.input_jog_dev);
1313 printk(KERN_INFO "%s input method installed.\n",
1314 sonypi_device.input_jog_dev.name);
1315
1316 /* Initialize the Input Drivers: special keys */
1317 sonypi_device.input_key_dev.evbit[0] = BIT(EV_KEY);
1318 for (i = 0; sonypi_inputkeys[i].sonypiev; i++)
1319 if (sonypi_inputkeys[i].inputev)
1320 set_bit(sonypi_inputkeys[i].inputev,
1321 sonypi_device.input_key_dev.keybit);
1322 sonypi_device.input_key_dev.name = SONYPI_KEY_INPUTNAME;
1323 sonypi_device.input_key_dev.id.bustype = BUS_ISA;
1324 sonypi_device.input_key_dev.id.vendor = PCI_VENDOR_ID_SONY;
1325 1336
1326 input_register_device(&sonypi_device.input_key_dev); 1337 ret = sonypi_create_input_devices();
1327 printk(KERN_INFO "%s input method installed.\n", 1338 if (ret)
1328 sonypi_device.input_key_dev.name); 1339 goto out_inputdevices;
1329 1340
1330 spin_lock_init(&sonypi_device.input_fifo_lock); 1341 spin_lock_init(&sonypi_device.input_fifo_lock);
1331 sonypi_device.input_fifo = 1342 sonypi_device.input_fifo =
@@ -1375,8 +1386,9 @@ static int __devinit sonypi_probe(void)
1375out_platformdev: 1386out_platformdev:
1376 kfifo_free(sonypi_device.input_fifo); 1387 kfifo_free(sonypi_device.input_fifo);
1377out_infifo: 1388out_infifo:
1378 input_unregister_device(&sonypi_device.input_key_dev); 1389 input_unregister_device(sonypi_device.input_key_dev);
1379 input_unregister_device(&sonypi_device.input_jog_dev); 1390 input_unregister_device(sonypi_device.input_jog_dev);
1391out_inputdevices:
1380 free_irq(sonypi_device.irq, sonypi_irq); 1392 free_irq(sonypi_device.irq, sonypi_irq);
1381out_reqirq: 1393out_reqirq:
1382 release_region(sonypi_device.ioport1, sonypi_device.region_size); 1394 release_region(sonypi_device.ioport1, sonypi_device.region_size);
@@ -1402,8 +1414,8 @@ static void __devexit sonypi_remove(void)
1402 platform_device_unregister(sonypi_device.pdev); 1414 platform_device_unregister(sonypi_device.pdev);
1403 1415
1404 if (useinput) { 1416 if (useinput) {
1405 input_unregister_device(&sonypi_device.input_key_dev); 1417 input_unregister_device(sonypi_device.input_key_dev);
1406 input_unregister_device(&sonypi_device.input_jog_dev); 1418 input_unregister_device(sonypi_device.input_jog_dev);
1407 kfifo_free(sonypi_device.input_fifo); 1419 kfifo_free(sonypi_device.input_fifo);
1408 } 1420 }
1409 1421