void intel_register_i2c_camera_device(struct sfi_device_table_entry *pentry, struct devs_id *dev) { struct i2c_board_info i2c_info; struct i2c_board_info *idev = &i2c_info; int bus = pentry->host_num; void *pdata = NULL; int n_subdev; const struct intel_v4l2_subdev_id *vdev = get_v4l2_ids(&n_subdev); struct intel_v4l2_subdev_i2c_board_info *info; static struct intel_v4l2_subdev_table *subdev_table; enum intel_v4l2_subdev_type type = 0; enum atomisp_camera_port port; static int i; if (vdev == NULL) { pr_info("ERROR: camera vdev list is NULL\n"); return; } memset(&i2c_info, 0, sizeof(i2c_info)); strncpy(i2c_info.type, pentry->name, SFI_NAME_LEN); i2c_info.irq = ((pentry->irq == (u8)0xff) ? 0 : pentry->irq); i2c_info.addr = pentry->addr; pr_info("camera pdata: I2C bus = %d, name = %16.16s, irq = 0x%2x, addr = 0x%x\n", pentry->host_num, i2c_info.type, i2c_info.irq, i2c_info.addr); if (!dev->get_platform_data) return; pdata = dev->get_platform_data(&i2c_info); i2c_info.platform_data = pdata; while (vdev->name[0]) { if (!strncmp(vdev->name, idev->type, 16)) { /* compare name */ type = vdev->type; port = vdev->port; break; } vdev++; } if (!type) /* not found */ return; info = kzalloc(sizeof(struct intel_v4l2_subdev_i2c_board_info), GFP_KERNEL); if (!info) { pr_err("MRST: fail to alloc mem for ignored i2c dev %s\n", idev->type); return; } info->i2c_adapter_id = bus; /* set platform data */ memcpy(&info->board_info, idev, sizeof(*idev)); if (atomisp_platform_data == NULL) { subdev_table = kzalloc(sizeof(struct intel_v4l2_subdev_table) * n_subdev, GFP_KERNEL); if (!subdev_table) { pr_err("MRST: fail to alloc mem for v4l2_subdev_table %s\n", idev->type); kfree(info); return; } atomisp_platform_data = kzalloc( sizeof(struct atomisp_platform_data), GFP_KERNEL); if (!atomisp_platform_data) { pr_err("%s: fail to alloc mem for atomisp_platform_data %s\n", __func__, idev->type); kfree(info); kfree(subdev_table); return; } i = 0; atomisp_platform_data->subdevs = subdev_table; } memcpy(&subdev_table[i].v4l2_subdev, info, sizeof(*info)); subdev_table[i].type = type; subdev_table[i].port = port; i++; kfree(info); return; }
void intel_register_i2c_camera_device(struct sfi_device_table_entry *pentry, struct devs_id *dev) { struct i2c_board_info i2c_info; struct i2c_board_info *idev = &i2c_info; int bus = pentry->host_num; void *pdata = NULL; int n_subdev; const struct intel_v4l2_subdev_id *vdev = get_v4l2_ids(&n_subdev); struct intel_v4l2_subdev_i2c_board_info *info; static struct intel_v4l2_subdev_table *subdev_table; enum intel_v4l2_subdev_type type = 0; enum atomisp_camera_port port; static int i; if (vdev == NULL) { pr_info("ERROR: camera vdev list is NULL\n"); return; } memset(&i2c_info, 0, sizeof(i2c_info)); //ASUS_BSP+++ if (PROJECT_ID == 0xFF) { PROJECT_ID = Read_PROJ_ID(); } pr_info("%s(%d):Project ID = %d\n", __func__, __LINE__, PROJECT_ID); #if 0 switch (PROJECT_ID) { case PROJ_ID_Z580C: if (!strncmp(pentry->name, "t4k35", 16)) { strncpy(pentry->name, "hm2051", SFI_NAME_LEN); pentry->addr = 0x24; pr_info("%s: Change sensor name\n", __func__); } break; default: break; } #endif //ASUS_BSP--- strncpy(i2c_info.type, pentry->name, SFI_NAME_LEN); i2c_info.irq = ((pentry->irq == (u8)0xff) ? 0 : pentry->irq); i2c_info.addr = pentry->addr; pr_info("camera pdata: I2C bus = %d, name = %16.16s, irq = 0x%2x, addr = 0x%x\n", pentry->host_num, i2c_info.type, i2c_info.irq, i2c_info.addr); if (!dev->get_platform_data) return; pdata = dev->get_platform_data(&i2c_info); i2c_info.platform_data = pdata; while (vdev->name[0]) { if (!strncmp(vdev->name, idev->type, 16)) { /* compare name */ type = vdev->type; port = vdev->port; break; } vdev++; } if (!type) /* not found */ return; info = kzalloc(sizeof(struct intel_v4l2_subdev_i2c_board_info), GFP_KERNEL); if (!info) { pr_err("MRST: fail to alloc mem for ignored i2c dev %s\n", idev->type); return; } info->i2c_adapter_id = bus; /* set platform data */ memcpy(&info->board_info, idev, sizeof(*idev)); if (atomisp_platform_data == NULL) { subdev_table = kzalloc(sizeof(struct intel_v4l2_subdev_table) * n_subdev, GFP_KERNEL); if (!subdev_table) { pr_err("MRST: fail to alloc mem for v4l2_subdev_table %s\n", idev->type); kfree(info); return; } atomisp_platform_data = kzalloc( sizeof(struct atomisp_platform_data), GFP_KERNEL); if (!atomisp_platform_data) { pr_err("%s: fail to alloc mem for atomisp_platform_data %s\n", __func__, idev->type); kfree(info); kfree(subdev_table); return; } i = 0; atomisp_platform_data->subdevs = subdev_table; } memcpy(&subdev_table[i].v4l2_subdev, info, sizeof(*info)); //ASUS_BSP+++ if (PROJECT_ID == 0xFF) { PROJECT_ID = Read_PROJ_ID(); } pr_info("%s(%d):Project ID = %d\n", __func__, __LINE__, PROJECT_ID); if (HW_ID == 0xFF) { HW_ID = Read_HW_ID(); } pr_info("%s(%d):HW ID = %d\n", __func__, __LINE__, HW_ID); if (PCB_ID == 0xFF) { PCB_ID = Read_PCB_ID(); pr_info("%s(%d):PCB ID = %x\n", __func__, __LINE__, PCB_ID); switch (PROJECT_ID) { case PROJ_ID_FE380CG: case PROJ_ID_FE380CXG: project_id = PCB_ID & 0x7; hardware_id = (PCB_ID & 0x38) >> 3; offset_0 = (PCB_ID & 0x40) >> 6; offset_1 = (PCB_ID & 0x180) >> 7; offset_2 = (PCB_ID & 0x1E00) >> 9; offset_3 = (PCB_ID & 0x6000) >> 13; offset_4 = (PCB_ID & 0x8000) >> 15; //offset_0: Panel ID, offset_1: TP_ID, offset_2: RF ID(last bit is SIM ID), offset_3: Main Camera ID, offset_4: Sub Camera ID //PCB_ID = pentry->project_id | pentry->hardware_id << 3 | pentry->offset_0 << 6 | pentry->offset_1 << 7 | pentry->offset_2 << 9 | pentry->offset_3 << 13 | pentry->offset_4 << 15; pr_info("%s: project id = %d, hardware id = %d, offset_0 = %d, offset_1 = %d, offset_2 = %d, offset_3 = %d, offset_4 = %d\n", __func__, project_id, hardware_id, offset_0, offset_1, offset_2, offset_3, offset_4); break; case PROJ_ID_Z580C: project_id = PCB_ID & 0x7; hardware_id = (PCB_ID & 0x38) >> 3; offset_0 = (PCB_ID & 0x40) >> 6; offset_1 = (PCB_ID & 0x80) >> 7; offset_2 = (PCB_ID & 0x700) >> 8; offset_3 = (PCB_ID & 0x1800) >> 11; offset_4 = (PCB_ID & 0x2000) >> 13; //offset_0: Panel ID, offset_1: Wifi ID, offset_2: RF ID, offset_3: Main Camera ID, offset_4: Sub Camera ID //PCB_ID = pentry->project_id | pentry->hardware_id << 3 | pentry->offset_0 << 6 | pentry->offset_1 << 7 | pentry->offset_2 << 8 | pentry->offset_3 << 11 | pentry->offset_4 << 13; pr_info("%s: project id = %d, hardware id = %d, offset_0 = %d, offset_1 = %d, offset_2 = %d, offset_3 = %d, offset_4 = %d\n", __func__, project_id, hardware_id, offset_0, offset_1, offset_2, offset_3, offset_4); break; default: break; } }