aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-rmi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-rmi.c')
-rw-r--r--drivers/hid/hid-rmi.c83
1 files changed, 63 insertions, 20 deletions
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 3cccff73b9b9..b51200fe2f33 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -584,11 +584,15 @@ static int rmi_populate_f11(struct hid_device *hdev)
584 bool has_query10 = false; 584 bool has_query10 = false;
585 bool has_query11; 585 bool has_query11;
586 bool has_query12; 586 bool has_query12;
587 bool has_query27;
588 bool has_query28;
589 bool has_query36 = false;
587 bool has_physical_props; 590 bool has_physical_props;
588 bool has_gestures; 591 bool has_gestures;
589 bool has_rel; 592 bool has_rel;
593 bool has_data40 = false;
590 unsigned x_size, y_size; 594 unsigned x_size, y_size;
591 u16 query12_offset; 595 u16 query_offset;
592 596
593 if (!data->f11.query_base_addr) { 597 if (!data->f11.query_base_addr) {
594 hid_err(hdev, "No 2D sensor found, giving up.\n"); 598 hid_err(hdev, "No 2D sensor found, giving up.\n");
@@ -604,6 +608,8 @@ static int rmi_populate_f11(struct hid_device *hdev)
604 has_query9 = !!(buf[0] & BIT(3)); 608 has_query9 = !!(buf[0] & BIT(3));
605 has_query11 = !!(buf[0] & BIT(4)); 609 has_query11 = !!(buf[0] & BIT(4));
606 has_query12 = !!(buf[0] & BIT(5)); 610 has_query12 = !!(buf[0] & BIT(5));
611 has_query27 = !!(buf[0] & BIT(6));
612 has_query28 = !!(buf[0] & BIT(7));
607 613
608 /* query 1 to get the max number of fingers */ 614 /* query 1 to get the max number of fingers */
609 ret = rmi_read(hdev, data->f11.query_base_addr + 1, buf); 615 ret = rmi_read(hdev, data->f11.query_base_addr + 1, buf);
@@ -626,43 +632,43 @@ static int rmi_populate_f11(struct hid_device *hdev)
626 has_rel = !!(buf[0] & BIT(3)); 632 has_rel = !!(buf[0] & BIT(3));
627 has_gestures = !!(buf[0] & BIT(5)); 633 has_gestures = !!(buf[0] & BIT(5));
628 634
635 /*
636 * At least 4 queries are guaranteed to be present in F11
637 * +1 for query 5 which is present since absolute events are
638 * reported and +1 for query 12.
639 */
640 query_offset = 6;
641
642 if (has_rel)
643 ++query_offset; /* query 6 is present */
644
629 if (has_gestures) { 645 if (has_gestures) {
630 /* query 8 to find out if query 10 exists */ 646 /* query 8 to find out if query 10 exists */
631 ret = rmi_read(hdev, data->f11.query_base_addr + 8, buf); 647 ret = rmi_read(hdev,
648 data->f11.query_base_addr + query_offset + 1, buf);
632 if (ret) { 649 if (ret) {
633 hid_err(hdev, "can not read gesture information: %d.\n", 650 hid_err(hdev, "can not read gesture information: %d.\n",
634 ret); 651 ret);
635 return ret; 652 return ret;
636 } 653 }
637 has_query10 = !!(buf[0] & BIT(2)); 654 has_query10 = !!(buf[0] & BIT(2));
638 }
639 655
640 /* 656 query_offset += 2; /* query 7 and 8 are present */
641 * At least 4 queries are guaranteed to be present in F11 657 }
642 * +1 for query 5 which is present since absolute events are
643 * reported and +1 for query 12.
644 */
645 query12_offset = 6;
646
647 if (has_rel)
648 ++query12_offset; /* query 6 is present */
649
650 if (has_gestures)
651 query12_offset += 2; /* query 7 and 8 are present */
652 658
653 if (has_query9) 659 if (has_query9)
654 ++query12_offset; 660 ++query_offset;
655 661
656 if (has_query10) 662 if (has_query10)
657 ++query12_offset; 663 ++query_offset;
658 664
659 if (has_query11) 665 if (has_query11)
660 ++query12_offset; 666 ++query_offset;
661 667
662 /* query 12 to know if the physical properties are reported */ 668 /* query 12 to know if the physical properties are reported */
663 if (has_query12) { 669 if (has_query12) {
664 ret = rmi_read(hdev, data->f11.query_base_addr 670 ret = rmi_read(hdev, data->f11.query_base_addr
665 + query12_offset, buf); 671 + query_offset, buf);
666 if (ret) { 672 if (ret) {
667 hid_err(hdev, "can not get query 12: %d.\n", ret); 673 hid_err(hdev, "can not get query 12: %d.\n", ret);
668 return ret; 674 return ret;
@@ -670,9 +676,10 @@ static int rmi_populate_f11(struct hid_device *hdev)
670 has_physical_props = !!(buf[0] & BIT(5)); 676 has_physical_props = !!(buf[0] & BIT(5));
671 677
672 if (has_physical_props) { 678 if (has_physical_props) {
679 query_offset += 1;
673 ret = rmi_read_block(hdev, 680 ret = rmi_read_block(hdev,
674 data->f11.query_base_addr 681 data->f11.query_base_addr
675 + query12_offset + 1, buf, 4); 682 + query_offset, buf, 4);
676 if (ret) { 683 if (ret) {
677 hid_err(hdev, "can not read query 15-18: %d.\n", 684 hid_err(hdev, "can not read query 15-18: %d.\n",
678 ret); 685 ret);
@@ -687,9 +694,45 @@ static int rmi_populate_f11(struct hid_device *hdev)
687 694
688 hid_info(hdev, "%s: size in mm: %d x %d\n", 695 hid_info(hdev, "%s: size in mm: %d x %d\n",
689 __func__, data->x_size_mm, data->y_size_mm); 696 __func__, data->x_size_mm, data->y_size_mm);
697
698 /*
699 * query 15 - 18 contain the size of the sensor
700 * and query 19 - 26 contain bezel dimensions
701 */
702 query_offset += 12;
703 }
704 }
705
706 if (has_query27)
707 ++query_offset;
708
709 if (has_query28) {
710 ret = rmi_read(hdev, data->f11.query_base_addr
711 + query_offset, buf);
712 if (ret) {
713 hid_err(hdev, "can not get query 28: %d.\n", ret);
714 return ret;
715 }
716
717 has_query36 = !!(buf[0] & BIT(6));
718 }
719
720 if (has_query36) {
721 query_offset += 2;
722 ret = rmi_read(hdev, data->f11.query_base_addr
723 + query_offset, buf);
724 if (ret) {
725 hid_err(hdev, "can not get query 36: %d.\n", ret);
726 return ret;
690 } 727 }
728
729 has_data40 = !!(buf[0] & BIT(5));
691 } 730 }
692 731
732
733 if (has_data40)
734 data->f11.report_size += data->max_fingers * 2;
735
693 /* 736 /*
694 * retrieve the ctrl registers 737 * retrieve the ctrl registers
695 * the ctrl register has a size of 20 but a fw bug split it into 16 + 4, 738 * the ctrl register has a size of 20 but a fw bug split it into 16 + 4,