static int get_panel_coordinate(struct mdnie_info *mdnie, int *result) { int ret = 0; char *fp = NULL; unsigned int coordinate[2] = {0,}; ret = mdnie_open_file(PANEL_COORDINATE_PATH, &fp); if (IS_ERR_OR_NULL(fp) || ret <= 0) { dev_info(mdnie->dev, "%s: open skip: %s, %d\n", __func__, PANEL_COORDINATE_PATH, ret); ret = -EINVAL; goto skip_color_correction; } ret = sscanf(fp, "%d, %d", &coordinate[0], &coordinate[1]); if (!(coordinate[0] + coordinate[1]) || ret != 2) { dev_info(mdnie->dev, "%s: %d, %d\n", __func__, coordinate[0], coordinate[1]); ret = -EINVAL; goto skip_color_correction; } ret = mdnie_calibration(coordinate[0], coordinate[1], result); dev_info(mdnie->dev, "%s: %d, %d, idx=%d\n", __func__, coordinate[0], coordinate[1], ret - 1); skip_color_correction: mdnie->color_correction = 1; if (!IS_ERR_OR_NULL(fp)) kfree(fp); return ret; }
int mdnie_request_firmware(const char *path, u16 **buf, char *name) { char *token, *ptr = NULL; unsigned short *dp; int ret = 0, size, i = 0; unsigned int data1, data2; size = mdnie_open_file(path, &ptr); if (IS_ERR_OR_NULL(ptr) || size <= 0) { pr_err("%s: file open fail %s\n", __func__, path); KFREE(ptr); return ret; } dp = kzalloc(size, GFP_KERNEL); if (dp == NULL) { pr_err("%s: Out of Memory\n", __func__); KFREE(ptr); return -ENOMEM; } if (name) { if (strstr(ptr, name) != NULL) { pr_info("found %s in %s\n", name, path); ptr = strstr(ptr, name); } } while ((token = strsep(&ptr, "\r\n")) != NULL) { if ((name) && (!strncmp(token, "};", 2))) { pr_info("found %s end in local, stop searching\n", name); break; } ret = sscanf(token, "%x, %x", &data1, &data2); if (ret == 2) { dp[i] = (u16)data1; dp[i+1] = (u16)data2; i += 2; } } dp[i] = END_SEQ; *buf = dp; KFREE(ptr); return i; }
int mdnie_check_firmware(const char *path, char *name) { char *ptr = NULL; int ret = 0, size; size = mdnie_open_file(path, &ptr); if (IS_ERR_OR_NULL(ptr) || size <= 0) { pr_err("%s: file open fail %s\n", __func__, path); KFREE(ptr); return 0; } ret = (strstr(ptr, name) != NULL) ? 1 : 0; KFREE(ptr); return ret; }
static int mdnie_request_firmware(char *path, char *name, mdnie_t **buf) { char *token, *ptr = NULL; int ret = 0, size; unsigned int data[2], i = 0, j; mdnie_t *dp; size = mdnie_open_file(path, &ptr); if (IS_ERR_OR_NULL(ptr) || size <= 0) { pr_err("%s: file open skip %s\n", __func__, path); kfree(ptr); return -EPERM; } dp = kzalloc(size, GFP_KERNEL); if (dp == NULL) { pr_err("%s: fail to alloc size %d\n", __func__, size); kfree(ptr); return -ENOMEM; } if (name) { if (strstr(ptr, name) != NULL) { pr_info("found %s in %s\n", name, path); ptr = strstr(ptr, name); } } while ((token = strsep(&ptr, "\r\n")) != NULL) { if (name && !strncmp(token, "};", 2)) { pr_info("found %s end in local, stop searching\n", name); break; } ret = sscanf(token, "%x, %x", &data[0], &data[1]); for (j = 0; j < ret; i++, j++) dp[i] = data[j]; } *buf = dp; kfree(ptr); return i; }