aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-wacom.c
diff options
context:
space:
mode:
authorPrzemo Firszt <przemo@firszt.eu>2010-03-22 04:55:04 -0400
committerJiri Kosina <jkosina@suse.cz>2010-03-22 04:55:04 -0400
commit06c7c313b5605471e321337c770683cf70464197 (patch)
treea6ad2c351bef6bee64df5504a6a51933fba838bf /drivers/hid/hid-wacom.c
parent59d2334ac9f4255f5f8f3e4e1bf41653e0bba99e (diff)
HID: separate mode switching function for wacom bluetooth driver
wacom_poke function allows to switch tablet reporting speed. The patch dosen't add any new functionality, but it's preparation for user-space speed switching through sysfs. Signed-off-by: Przemo Firszt <przemo@firszt.eu> Signed-off-by: Bastien Nocera <hadess@hadess.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-wacom.c')
-rw-r--r--drivers/hid/hid-wacom.c66
1 files changed, 40 insertions, 26 deletions
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index 4d2d2a2e1a5f..f9d493931b02 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -103,6 +103,44 @@ static int wacom_ac_get_property(struct power_supply *psy,
103} 103}
104#endif 104#endif
105 105
106static void wacom_poke(struct hid_device *hdev, u8 speed)
107{
108 int limit, ret;
109 char rep_data[2];
110
111 rep_data[0] = 0x03 ; rep_data[1] = 0x00;
112 limit = 3;
113 do {
114 ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
115 HID_FEATURE_REPORT);
116 } while (ret < 0 && limit-- > 0);
117
118 if (ret >= 0) {
119 if (speed == 0)
120 rep_data[0] = 0x05;
121 else
122 rep_data[0] = 0x06;
123
124 rep_data[1] = 0x00;
125 limit = 3;
126 do {
127 ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
128 HID_FEATURE_REPORT);
129 } while (ret < 0 && limit-- > 0);
130
131 if (ret >= 0)
132 return;
133 }
134
135 /*
136 * Note that if the raw queries fail, it's not a hard failure and it
137 * is safe to continue
138 */
139 dev_warn(&hdev->dev, "failed to poke device, command %d, err %d\n",
140 rep_data[0], ret);
141 return;
142}
143
106static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, 144static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
107 u8 *raw_data, int size) 145 u8 *raw_data, int size)
108{ 146{
@@ -236,9 +274,7 @@ static int wacom_probe(struct hid_device *hdev,
236 struct hid_input *hidinput; 274 struct hid_input *hidinput;
237 struct input_dev *input; 275 struct input_dev *input;
238 struct wacom_data *wdata; 276 struct wacom_data *wdata;
239 char rep_data[2];
240 int ret; 277 int ret;
241 int limit;
242 278
243 wdata = kzalloc(sizeof(*wdata), GFP_KERNEL); 279 wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
244 if (wdata == NULL) { 280 if (wdata == NULL) {
@@ -261,30 +297,8 @@ static int wacom_probe(struct hid_device *hdev,
261 goto err_free; 297 goto err_free;
262 } 298 }
263 299
264 /* 300 /* Set Wacom mode 2 with high reporting speed */
265 * Note that if the raw queries fail, it's not a hard failure and it 301 wacom_poke(hdev, 1);
266 * is safe to continue
267 */
268
269 /* Set Wacom mode2 */
270 rep_data[0] = 0x03; rep_data[1] = 0x00;
271 limit = 3;
272 do {
273 ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
274 HID_FEATURE_REPORT);
275 } while (ret < 0 && limit-- > 0);
276 if (ret < 0)
277 dev_warn(&hdev->dev, "failed to poke device #1, %d\n", ret);
278
279 /* 0x06 - high reporting speed, 0x05 - low speed */
280 rep_data[0] = 0x06; rep_data[1] = 0x00;
281 limit = 3;
282 do {
283 ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
284 HID_FEATURE_REPORT);
285 } while (ret < 0 && limit-- > 0);
286 if (ret < 0)
287 dev_warn(&hdev->dev, "failed to poke device #2, %d\n", ret);
288 302
289#ifdef CONFIG_HID_WACOM_POWER_SUPPLY 303#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
290 wdata->battery.properties = wacom_battery_props; 304 wdata->battery.properties = wacom_battery_props;