aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2014-08-06 16:48:01 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-08-06 17:18:10 -0400
commitf81a1295cd9b6d3d3d7d7126e522d80917134b41 (patch)
tree9b5da4c5cd0920865ce2a306bedda8a7807dfc0e /drivers
parentaeaf50d4e7d29d9a5f6da45fdcd9fb118f70fb93 (diff)
Input: wacom - prepare the driver to include BT devices
Now that wacom is a hid driver, there is no point in having a separate driver for bluetooth devices. This patch prepares the common paths of Bluetooth devices in the common wacom driver. It also adds the sysfs file "speed" used by Bluetooth devices. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Ping Cheng <pingc@wacom.com> Tested-by: Przemo Firszt <przemo@firszt.eu> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/wacom_sys.c70
-rw-r--r--drivers/hid/wacom_wac.h2
2 files changed, 69 insertions, 3 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 37888c3f39ba..18154a5459b5 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -262,6 +262,12 @@ static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
262 return error < 0 ? error : 0; 262 return error < 0 ? error : 0;
263} 263}
264 264
265static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
266 struct wacom_features *features)
267{
268 return 0;
269}
270
265/* 271/*
266 * Switch the tablet into its most-capable mode. Wacom tablets are 272 * Switch the tablet into its most-capable mode. Wacom tablets are
267 * typically configured to power-up in a mode which sends mouse-like 273 * typically configured to power-up in a mode which sends mouse-like
@@ -272,6 +278,9 @@ static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
272static int wacom_query_tablet_data(struct hid_device *hdev, 278static int wacom_query_tablet_data(struct hid_device *hdev,
273 struct wacom_features *features) 279 struct wacom_features *features)
274{ 280{
281 if (hdev->bus == BUS_BLUETOOTH)
282 return wacom_bt_query_tablet_data(hdev, 1, features);
283
275 if (features->device_type == BTN_TOOL_FINGER) { 284 if (features->device_type == BTN_TOOL_FINGER) {
276 if (features->type > TABLETPC) { 285 if (features->type > TABLETPC) {
277 /* MT Tablet PC touch */ 286 /* MT Tablet PC touch */
@@ -890,6 +899,38 @@ static void wacom_destroy_battery(struct wacom *wacom)
890 } 899 }
891} 900}
892 901
902static ssize_t wacom_show_speed(struct device *dev,
903 struct device_attribute
904 *attr, char *buf)
905{
906 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
907 struct wacom *wacom = hid_get_drvdata(hdev);
908
909 return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed);
910}
911
912static ssize_t wacom_store_speed(struct device *dev,
913 struct device_attribute *attr,
914 const char *buf, size_t count)
915{
916 struct hid_device *hdev = container_of(dev, struct hid_device, dev);
917 struct wacom *wacom = hid_get_drvdata(hdev);
918 u8 new_speed;
919
920 if (kstrtou8(buf, 0, &new_speed))
921 return -EINVAL;
922
923 if (new_speed != 0 && new_speed != 1)
924 return -EINVAL;
925
926 wacom_bt_query_tablet_data(hdev, new_speed, &wacom->wacom_wac.features);
927
928 return count;
929}
930
931static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR | S_IWGRP,
932 wacom_show_speed, wacom_store_speed);
933
893static struct input_dev *wacom_allocate_input(struct wacom *wacom) 934static struct input_dev *wacom_allocate_input(struct wacom *wacom)
894{ 935{
895 struct input_dev *input_dev; 936 struct input_dev *input_dev;
@@ -1210,6 +1251,9 @@ static int wacom_probe(struct hid_device *hdev,
1210 features->y_max = 4096; 1251 features->y_max = 4096;
1211 } 1252 }
1212 1253
1254 if (hdev->bus == BUS_BLUETOOTH)
1255 features->quirks |= WACOM_QUIRK_BATTERY;
1256
1213 wacom_setup_device_quirks(features); 1257 wacom_setup_device_quirks(features);
1214 1258
1215 /* set unit to "100th of a mm" for devices not reported by HID */ 1259 /* set unit to "100th of a mm" for devices not reported by HID */
@@ -1241,10 +1285,25 @@ static int wacom_probe(struct hid_device *hdev,
1241 if (error) 1285 if (error)
1242 goto fail2; 1286 goto fail2;
1243 1287
1288 if (!(features->quirks & WACOM_QUIRK_MONITOR) &&
1289 (features->quirks & WACOM_QUIRK_BATTERY)) {
1290 error = wacom_initialize_battery(wacom);
1291 if (error)
1292 goto fail3;
1293 }
1294
1244 if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { 1295 if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
1245 error = wacom_register_inputs(wacom); 1296 error = wacom_register_inputs(wacom);
1246 if (error) 1297 if (error)
1247 goto fail3; 1298 goto fail4;
1299 }
1300
1301 if (hdev->bus == BUS_BLUETOOTH) {
1302 error = device_create_file(&hdev->dev, &dev_attr_speed);
1303 if (error)
1304 hid_warn(hdev,
1305 "can't create sysfs speed attribute err: %d\n",
1306 error);
1248 } 1307 }
1249 1308
1250 /* Note that if query fails it is not a hard failure */ 1309 /* Note that if query fails it is not a hard failure */
@@ -1254,7 +1313,7 @@ static int wacom_probe(struct hid_device *hdev,
1254 error = hid_hw_start(hdev, HID_CONNECT_HIDRAW); 1313 error = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
1255 if (error) { 1314 if (error) {
1256 hid_err(hdev, "hw start failed\n"); 1315 hid_err(hdev, "hw start failed\n");
1257 goto fail4; 1316 goto fail5;
1258 } 1317 }
1259 1318
1260 if (features->quirks & WACOM_QUIRK_MONITOR) 1319 if (features->quirks & WACOM_QUIRK_MONITOR)
@@ -1267,7 +1326,10 @@ static int wacom_probe(struct hid_device *hdev,
1267 1326
1268 return 0; 1327 return 0;
1269 1328
1270 fail4: wacom_unregister_inputs(wacom); 1329 fail5: if (hdev->bus == BUS_BLUETOOTH)
1330 device_remove_file(&hdev->dev, &dev_attr_speed);
1331 wacom_unregister_inputs(wacom);
1332 fail4: wacom_destroy_battery(wacom);
1271 fail3: wacom_destroy_leds(wacom); 1333 fail3: wacom_destroy_leds(wacom);
1272 fail2: wacom_remove_shared_data(wacom_wac); 1334 fail2: wacom_remove_shared_data(wacom_wac);
1273 fail1: kfree(wacom); 1335 fail1: kfree(wacom);
@@ -1283,6 +1345,8 @@ static void wacom_remove(struct hid_device *hdev)
1283 1345
1284 cancel_work_sync(&wacom->work); 1346 cancel_work_sync(&wacom->work);
1285 wacom_unregister_inputs(wacom); 1347 wacom_unregister_inputs(wacom);
1348 if (hdev->bus == BUS_BLUETOOTH)
1349 device_remove_file(&hdev->dev, &dev_attr_speed);
1286 wacom_destroy_battery(wacom); 1350 wacom_destroy_battery(wacom);
1287 wacom_destroy_leds(wacom); 1351 wacom_destroy_leds(wacom);
1288 wacom_remove_shared_data(&wacom->wacom_wac); 1352 wacom_remove_shared_data(&wacom->wacom_wac);
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index 3433a0e28bb4..6cefa1e8c14b 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -169,6 +169,8 @@ struct wacom_wac {
169 int num_contacts_left; 169 int num_contacts_left;
170 int bat_charging; 170 int bat_charging;
171 int ps_connected; 171 int ps_connected;
172 u8 bt_features;
173 u8 bt_high_speed;
172}; 174};
173 175
174#endif 176#endif