Skip to content

Commit

Permalink
Implment configuration reading
Browse files Browse the repository at this point in the history
  • Loading branch information
lazd committed Jan 5, 2020
1 parent b705eb4 commit 6d8270f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
48 changes: 45 additions & 3 deletions VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp
Expand Up @@ -345,15 +345,57 @@ IOReturn VoodooI2CGoodixTouchDriver::goodix_read_version(struct goodix_ts_data *
return retVal;
}

IOReturn VoodooI2CGoodixTouchDriver::goodix_configure_dev(struct goodix_ts_data *ts) {
void VoodooI2CGoodixTouchDriver::goodix_read_config(struct goodix_ts_data *ts) {
UInt8 config[GOODIX_CONFIG_MAX_LENGTH];
IOReturn retVal = kIOReturnSuccess;

return retVal;
retVal = goodix_read_reg(ts->chip->config_addr, config, ts->chip->config_len);

if (retVal != kIOReturnSuccess) {
IOLog("%s::Error reading config (%d), using defaults\n", getName(), retVal);
ts->abs_x_max = GOODIX_MAX_WIDTH;
ts->abs_y_max = GOODIX_MAX_HEIGHT;
// if (ts->swapped_x_y)
// swap(ts->abs_x_max, ts->abs_y_max);
ts->int_trigger_type = GOODIX_INT_TRIGGER;
ts->max_touch_num = GOODIX_MAX_CONTACTS;
return;
}

ts->abs_x_max = get_unaligned_le16(&config[RESOLUTION_LOC]);
ts->abs_y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]);
// if (ts->swapped_x_y)
// swap(ts->abs_x_max, ts->abs_y_max);
ts->int_trigger_type = config[TRIGGER_LOC] & 0x03;
ts->max_touch_num = config[MAX_CONTACTS_LOC] & 0x0f;
if (!ts->abs_x_max || !ts->abs_y_max || !ts->max_touch_num) {
IOLog("%s::Invalid config (%d), using defaults\n", getName(), retVal);
ts->abs_x_max = GOODIX_MAX_WIDTH;
ts->abs_y_max = GOODIX_MAX_HEIGHT;
// if (ts->swapped_x_y)
// swap(ts->abs_x_max, ts->abs_y_max);
ts->max_touch_num = GOODIX_MAX_CONTACTS;
}

IOLog("%s::Config read successfully\n", getName());

IOLog("%s::ts->abs_x_max = %d\n", getName(), ts->abs_x_max);
IOLog("%s::ts->abs_y_max = %d\n", getName(), ts->abs_y_max);
IOLog("%s::ts->int_trigger_type = %d\n", getName(), ts->int_trigger_type);
IOLog("%s::ts->max_touch_num = %d\n", getName(), ts->max_touch_num);

// if (dmi_check_system(rotated_screen)) {
// ts->inverted_x = true;
// ts->inverted_y = true;
// IOLog("%s::Applying '180 degrees rotated screen' quirk\n");
// }
}

IOReturn VoodooI2CGoodixTouchDriver::goodix_read_config(struct goodix_ts_data *ts) {
IOReturn VoodooI2CGoodixTouchDriver::goodix_configure_dev(struct goodix_ts_data *ts) {
IOReturn retVal = kIOReturnSuccess;

goodix_read_config(ts);

return retVal;
}

Expand Down
2 changes: 1 addition & 1 deletion VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.hpp
Expand Up @@ -108,7 +108,7 @@ class VoodooI2CGoodixTouchDriver : public IOService {
*
* @ts: our goodix_ts_data pointer
*/
IOReturn goodix_read_config(struct goodix_ts_data *ts);
void goodix_read_config(struct goodix_ts_data *ts);
};

#endif /* VoodooI2CGoodixTouchDriver_hpp */
10 changes: 10 additions & 0 deletions VoodooI2CGoodix/goodix.h
Expand Up @@ -12,6 +12,16 @@
#define GOODIX_CONFIG_911_LENGTH 186
#define GOODIX_CONFIG_967_LENGTH 228

#define GOODIX_MAX_HEIGHT 4096
#define GOODIX_MAX_WIDTH 4096
#define GOODIX_INT_TRIGGER 1
#define GOODIX_CONTACT_SIZE 8
#define GOODIX_MAX_CONTACTS 10

#define RESOLUTION_LOC 1
#define MAX_CONTACTS_LOC 5
#define TRIGGER_LOC 6

#define msleep(x) IOSleep(x)
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
#define usleep_range(min, max) msleep(DIV_ROUND_UP(min, 1000))
Expand Down

0 comments on commit 6d8270f

Please sign in to comment.