struct amd_input_data *in_data = cli_data->in_data;
struct request_list *req_node;
u8 current_index, sensor_index;
+ struct amd_mp2_ops *mp2_ops;
+ struct amd_mp2_dev *mp2;
u8 report_id, node_type;
u8 report_size = 0;
node_type = req_node->report_type;
kfree(req_node);
+ mp2 = container_of(in_data, struct amd_mp2_dev, in_data);
+ mp2_ops = mp2->mp2_ops;
if (node_type == HID_FEATURE_REPORT) {
- report_size = get_feature_report(sensor_index, report_id,
- cli_data->feature_report[current_index]);
+ report_size = mp2_ops->get_feat_rep(sensor_index, report_id,
+ cli_data->feature_report[current_index]);
if (report_size)
hid_input_report(cli_data->hid_sensor_hubs[current_index],
cli_data->report_type[current_index],
pr_err("AMDSFH: Invalid report size\n");
} else if (node_type == HID_INPUT_REPORT) {
- report_size = get_input_report(current_index, sensor_index, report_id, in_data);
+ report_size = mp2_ops->get_in_rep(current_index, sensor_index, report_id, in_data);
if (report_size)
hid_input_report(cli_data->hid_sensor_hubs[current_index],
cli_data->report_type[current_index],
{
struct amdtp_cl_data *cli_data = container_of(work, struct amdtp_cl_data, work_buffer.work);
struct amd_input_data *in_data = cli_data->in_data;
+ struct amd_mp2_dev *mp2;
u8 report_size;
int i;
for (i = 0; i < cli_data->num_hid_devices; i++) {
if (cli_data->sensor_sts[i] == SENSOR_ENABLED) {
- report_size = get_input_report
- (i, cli_data->sensor_idx[i], cli_data->report_id[i], in_data);
+ mp2 = container_of(in_data, struct amd_mp2_dev, in_data);
+ report_size = mp2->mp2_ops->get_in_rep(i, cli_data->sensor_idx[i],
+ cli_data->report_id[i], in_data);
hid_input_report(cli_data->hid_sensor_hubs[i], HID_INPUT_REPORT,
in_data->input_report[i], report_size, 0);
}
{
struct amd_input_data *in_data = &privdata->in_data;
struct amdtp_cl_data *cl_data = privdata->cl_data;
+ struct amd_mp2_ops *mp2_ops = privdata->mp2_ops;
struct amd_mp2_sensor_info info;
struct request_list *req_list;
struct device *dev;
req_list = &cl_data->req_list;
dev = &privdata->pdev->dev;
+ amd_sfh_set_desc_ops(mp2_ops);
cl_data->num_hid_devices = amd_mp2_get_sensor_num(privdata, &cl_data->sensor_idx[0]);
cl_data->sensor_requested_cnt[i] = 0;
cl_data->cur_hid_dev = i;
cl_idx = cl_data->sensor_idx[i];
- cl_data->report_descr_sz[i] = get_descr_sz(cl_idx, descr_size);
+ cl_data->report_descr_sz[i] = mp2_ops->get_desc_sz(cl_idx, descr_size);
if (!cl_data->report_descr_sz[i]) {
rc = -EINVAL;
goto cleanup;
}
- feature_report_size = get_descr_sz(cl_idx, feature_size);
+ feature_report_size = mp2_ops->get_desc_sz(cl_idx, feature_size);
if (!feature_report_size) {
rc = -EINVAL;
goto cleanup;
}
- input_report_size = get_descr_sz(cl_idx, input_size);
+ input_report_size = mp2_ops->get_desc_sz(cl_idx, input_size);
if (!input_report_size) {
rc = -EINVAL;
goto cleanup;
rc = -ENOMEM;
goto cleanup;
}
- rc = get_report_descriptor(cl_idx, cl_data->report_descr[i]);
+ rc = mp2_ops->get_rep_desc(cl_idx, cl_data->report_descr[i]);
if (rc)
return rc;
- privdata->mp2_ops->start(privdata, info);
+ mp2_ops->start(privdata, info);
status = amd_sfh_wait_for_response
(privdata, cl_data->sensor_idx[i], SENSOR_ENABLED);
if (status == SENSOR_ENABLED) {
cl_data->sensor_sts[i] = SENSOR_ENABLED;
rc = amdtp_hid_probe(cl_data->cur_hid_dev, cl_data);
if (rc) {
- privdata->mp2_ops->stop(privdata, cl_data->sensor_idx[i]);
+ mp2_ops->stop(privdata, cl_data->sensor_idx[i]);
status = amd_sfh_wait_for_response
(privdata, cl_data->sensor_idx[i], SENSOR_DISABLED);
if (status != SENSOR_ENABLED)
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
cl_data->sensor_sts[i]);
}
- if (privdata->mp2_ops->discovery_status &&
- privdata->mp2_ops->discovery_status(privdata) == 0) {
+ if (mp2_ops->discovery_status && mp2_ops->discovery_status(privdata) == 0) {
amd_sfh_hid_client_deinit(privdata);
for (i = 0; i < cl_data->num_hid_devices; i++) {
devm_kfree(dev, cl_data->feature_report[i]);
#define HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM 0x04
#define ILLUMINANCE_MASK GENMASK(14, 0)
-int get_report_descriptor(int sensor_idx, u8 *rep_desc)
+static int get_report_descriptor(int sensor_idx, u8 *rep_desc)
{
switch (sensor_idx) {
case accel_idx: /* accel */
return 0;
}
-u32 get_descr_sz(int sensor_idx, int descriptor_name)
+static u32 get_descr_sz(int sensor_idx, int descriptor_name)
{
switch (sensor_idx) {
case accel_idx:
common->report_interval = HID_DEFAULT_REPORT_INTERVAL;
}
-u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report)
+static u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report)
{
struct accel3_feature_report acc_feature;
struct gyro_feature_report gyro_feature;
common->event_type = HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM;
}
-u8 get_input_report(u8 current_index, int sensor_idx, int report_id, struct amd_input_data *in_data)
+static u8 get_input_report(u8 current_index, int sensor_idx, int report_id,
+ struct amd_input_data *in_data)
{
struct amd_mp2_dev *privdata = container_of(in_data, struct amd_mp2_dev, in_data);
u32 *sensor_virt_addr = in_data->sensor_virt_addr[current_index];
}
return report_size;
}
+
+void amd_sfh_set_desc_ops(struct amd_mp2_ops *mp2_ops)
+{
+ mp2_ops->get_rep_desc = get_report_descriptor;
+ mp2_ops->get_feat_rep = get_feature_report;
+ mp2_ops->get_in_rep = get_input_report;
+ mp2_ops->get_desc_sz = get_descr_sz;
+}