aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Duggan <aduggan@synaptics.com>2014-05-02 14:14:16 -0400
committerJiri Kosina <jkosina@suse.cz>2014-05-13 10:37:43 -0400
commitf15475c397f496c0907be5e95f8556c8f5908d54 (patch)
tree601d1433558f22197b47b8f4baba92fbc30aed3b
parentb89f991af08244121e69a3ee90cfa397598cf3ab (diff)
HID: rmi: check for the existence of some optional queries before reading query 12
The rmi4 spec defines some optional query registers in F11 which appear before query 12. This patch checks for the existence of some of the lesser used queries to compute the location of query12 and all subsequent query registers. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-rmi.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 7da9509894de..eda7ef41c291 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -546,9 +546,13 @@ static int rmi_populate_f11(struct hid_device *hdev)
546 struct rmi_data *data = hid_get_drvdata(hdev); 546 struct rmi_data *data = hid_get_drvdata(hdev);
547 u8 buf[20]; 547 u8 buf[20];
548 int ret; 548 int ret;
549 bool has_query9;
550 bool has_query10;
551 bool has_query11;
549 bool has_query12; 552 bool has_query12;
550 bool has_physical_props; 553 bool has_physical_props;
551 unsigned x_size, y_size; 554 unsigned x_size, y_size;
555 u16 query12_offset;
552 556
553 if (!data->f11.query_base_addr) { 557 if (!data->f11.query_base_addr) {
554 hid_err(hdev, "No 2D sensor found, giving up.\n"); 558 hid_err(hdev, "No 2D sensor found, giving up.\n");
@@ -561,6 +565,8 @@ static int rmi_populate_f11(struct hid_device *hdev)
561 hid_err(hdev, "can not get query 0: %d.\n", ret); 565 hid_err(hdev, "can not get query 0: %d.\n", ret);
562 return ret; 566 return ret;
563 } 567 }
568 has_query9 = !!(buf[0] & BIT(3));
569 has_query11 = !!(buf[0] & BIT(4));
564 has_query12 = !!(buf[0] & BIT(5)); 570 has_query12 = !!(buf[0] & BIT(5));
565 571
566 /* query 1 to get the max number of fingers */ 572 /* query 1 to get the max number of fingers */
@@ -581,12 +587,33 @@ static int rmi_populate_f11(struct hid_device *hdev)
581 return -ENODEV; 587 return -ENODEV;
582 } 588 }
583 589
590 /* query 8 to find out if query 10 exists */
591 ret = rmi_read(hdev, data->f11.query_base_addr + 8, buf);
592 if (ret) {
593 hid_err(hdev, "can not read gesture information: %d.\n", ret);
594 return ret;
595 }
596 has_query10 = !!(buf[0] & BIT(2));
597
584 /* 598 /*
585 * query 12 to know if the physical properties are reported 599 * At least 8 queries are guaranteed to be present in F11
586 * (query 12 is at offset 10 for HID devices) 600 * +1 for query12.
587 */ 601 */
602 query12_offset = 9;
603
604 if (has_query9)
605 ++query12_offset;
606
607 if (has_query10)
608 ++query12_offset;
609
610 if (has_query11)
611 ++query12_offset;
612
613 /* query 12 to know if the physical properties are reported */
588 if (has_query12) { 614 if (has_query12) {
589 ret = rmi_read(hdev, data->f11.query_base_addr + 10, buf); 615 ret = rmi_read(hdev, data->f11.query_base_addr
616 + query12_offset, buf);
590 if (ret) { 617 if (ret) {
591 hid_err(hdev, "can not get query 12: %d.\n", ret); 618 hid_err(hdev, "can not get query 12: %d.\n", ret);
592 return ret; 619 return ret;
@@ -595,7 +622,8 @@ static int rmi_populate_f11(struct hid_device *hdev)
595 622
596 if (has_physical_props) { 623 if (has_physical_props) {
597 ret = rmi_read_block(hdev, 624 ret = rmi_read_block(hdev,
598 data->f11.query_base_addr + 11, buf, 4); 625 data->f11.query_base_addr
626 + query12_offset + 1, buf, 4);
599 if (ret) { 627 if (ret) {
600 hid_err(hdev, "can not read query 15-18: %d.\n", 628 hid_err(hdev, "can not read query 15-18: %d.\n",
601 ret); 629 ret);