diff --git a/drivers/media/i2c/d4xx.c b/drivers/media/i2c/d4xx.c index 403a347f5bac..430ab8b1eb56 100644 --- a/drivers/media/i2c/d4xx.c +++ b/drivers/media/i2c/d4xx.c @@ -828,7 +828,7 @@ static const struct ds5_resolution d46x_calibration_sizes[] = { static const struct ds5_resolution ds5_size_imu[] = { { - .width = 32, + .width = 32, .height = 1, .framerates = ds5_imu_framerates, .n_framerates = ARRAY_SIZE(ds5_imu_framerates), @@ -1017,8 +1017,8 @@ static int ds5_sensor_enum_mbus_code(struct v4l2_subdev *sd, { struct ds5_sensor *sensor = container_of(sd, struct ds5_sensor, sd); //struct ds5_vchan *vchan = sensor->vchan; -dev_info(sensor->sd.dev, "%s(): sensor %s pad: %d index: %d\n", -__func__, sensor->sd.name, mce->pad, mce->index); + dev_info(sensor->sd.dev, "%s(): sensor %s pad: %d index: %d\n", + __func__, sensor->sd.name, mce->pad, mce->index); if (mce->pad) return -EINVAL; @@ -1221,6 +1221,7 @@ static unsigned int mbus_code_to_mipi(u32 code) case MEDIA_BUS_FMT_SGRBG10_1X10: case MEDIA_BUS_FMT_SRGGB10_1X10: return MIPI_CSI2_TYPE_RAW10; + case MEDIA_BUS_FMT_Y8_1X8: case MEDIA_BUS_FMT_SBGGR8_1X8: case MEDIA_BUS_FMT_SGBRG8_1X8: case MEDIA_BUS_FMT_SGRBG8_1X8: @@ -1784,7 +1785,7 @@ static const struct v4l2_subdev_ops ds5_imu_subdev_ops = { static int ds5_hw_set_auto_exposure(struct ds5 *state, u32 base, s32 val) { if (val != V4L2_EXPOSURE_APERTURE_PRIORITY && - val != V4L2_EXPOSURE_MANUAL) + val != V4L2_EXPOSURE_MANUAL) return -EINVAL; /* @@ -2188,11 +2189,11 @@ static int ds5_s_ctrl(struct v4l2_ctrl *ctrl) sizeof(struct hwm_cmd) + 512); devm_kfree(&state->client->dev, calib_cmd); } - } break; case DS5_CAMERA_CID_AE_ROI_SET: { struct hwm_cmd ae_roi_cmd; + memcpy(&ae_roi_cmd, &set_ae_roi, sizeof(ae_roi_cmd)); ae_roi_cmd.param1 = *((u16*)ctrl->p_new.p_u16); ae_roi_cmd.param2 = *((u16*)ctrl->p_new.p_u16 + 1); @@ -2204,6 +2205,7 @@ static int ds5_s_ctrl(struct v4l2_ctrl *ctrl) } case DS5_CAMERA_CID_AE_SETPOINT_SET: { struct hwm_cmd *ae_setpoint_cmd; + if (ctrl->p_new.p_s32) { dev_dbg(&state->client->dev, "%s():0x%x \n", __func__, *(ctrl->p_new.p_s32)); @@ -2452,7 +2454,6 @@ static int ds5_gvd(struct ds5 *state, unsigned char *data) return ret; } - static int ds5_g_volatile_ctrl(struct v4l2_ctrl *ctrl) { struct ds5 *state = container_of(ctrl->handler, struct ds5, @@ -3138,10 +3139,8 @@ static int ds5_sensor_init(struct i2c_client *c, struct ds5 *state, struct media_entity *entity = &sensor->sd.entity; struct media_pad *pad = &sensor->pad; dev_t *dev_num = &state->client->dev.devt; - - dev_info(sd->dev, "%s(): %p %s %p %p", __func__, c, c->name, state, state->client); - struct d4xx_pdata *dpdata = c->dev.platform_data; + v4l2_i2c_subdev_init(sd, c, ops); sd->owner = NULL; sd->internal_ops = &ds5_sensor_internal_ops; @@ -3449,8 +3448,6 @@ static int ds5_mux_set_fmt(struct v4l2_subdev *sd, struct ds5 *state = container_of(sd, struct ds5, mux.sd.subdev); struct v4l2_mbus_framefmt *ffmt; struct ds5_sensor *sensor = state->mux.last_set; - - u32 pad = sensor->mux_pad; // u32 pad = fmt->pad; int ret = 0; @@ -3486,7 +3483,7 @@ static int ds5_mux_set_fmt(struct v4l2_subdev *sd, set_sub_stream_w(substream, ffmt->width); set_sub_stream_dt(substream, mbus_code_to_mipi(ffmt->code)); } - dev_info(sd->dev, "%s(): fmt->pad:%d, sensor->mux_pad: %d, code: 0x%x: %ux%u substream:%d for sensor: %s\n", __func__, + dev_dbg(sd->dev, "%s(): fmt->pad:%d, sensor->mux_pad: %d, code: 0x%x: %ux%u substream:%d for sensor: %s\n", __func__, fmt->pad, pad, fmt->format.code, fmt->format.width, fmt->format.height, substream, sensor->sd.name); return ret; @@ -3523,7 +3520,7 @@ static int ds5_mux_get_fmt(struct v4l2_subdev *sd, return -EINVAL; } - dev_info(sd->dev, "%s(): fmt->pad:%d, sensor->mux_pad:%u size:%d-%d, code:0x%x field:%d, color:%d\n", __func__, fmt->pad, pad, + dev_dbg(sd->dev, "%s(): fmt->pad:%d, sensor->mux_pad:%u size:%d-%d, code:0x%x field:%d, color:%d\n", __func__, fmt->pad, pad, fmt->format.width, fmt->format.height, fmt->format.code, fmt->format.field, fmt->format.colorspace); return ret; } @@ -4029,6 +4026,7 @@ static int ds5_mux_registered(struct v4l2_subdev *sd) static void ds5_mux_unregistered(struct v4l2_subdev *sd) { struct ds5 *state = v4l2_get_subdevdata(sd); + ds5_sensor_remove(&state->imu.sensor); ds5_sensor_remove(&state->rgb.sensor); ds5_sensor_remove(&state->motion_t.sensor); @@ -4111,7 +4109,6 @@ static int ds5_mux_init(struct i2c_client *c, struct ds5 *state) struct d4xx_pdata *dpdata = c->dev.platform_data; v4l2_i2c_subdev_init(sd, c, &ds5_mux_subdev_ops); - // Set owner to NULL so we can unload the driver module sd->owner = NULL; sd->internal_ops = &ds5_mux_internal_ops; @@ -4119,7 +4116,6 @@ static int ds5_mux_init(struct i2c_client *c, struct ds5 *state) snprintf(sd->name, sizeof(sd->name), "DS5 mux %c", dpdata->suffix); sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - entity->obj_type = MEDIA_ENTITY_TYPE_V4L2_SUBDEV; entity->function = MEDIA_ENT_F_CAM_SENSOR; @@ -4379,7 +4375,7 @@ static int ds5_dfu_switch_to_dfu(struct ds5 *state) do { msleep_range(DS5_START_POLL_TIME*10); ret = ds5_read(state, 0x5000, &status); - } while (ret && i-- ); + } while (ret && i--); return ret; }; @@ -4390,6 +4386,7 @@ static int ds5_dfu_wait_for_get_dfu_status(struct ds5 *state, u16 status,dfu_state_len = 0x0000; unsigned char dfu_asw_buf[DFU_WAIT_RET_LEN]; unsigned int dfu_wr_wait_msec = 0; + do { ds5_write_with_check(state, 0x5008, 0x0003); // Get Write state do { @@ -4422,7 +4419,6 @@ static int ds5_dfu_wait_for_get_dfu_status(struct ds5 *state, | dfu_asw_buf[1]; } while (dfu_asw_buf[4] == dfuDNBUSY && exp_state == dfuDNLOAD_IDLE); - if (dfu_asw_buf[4] != exp_state) { dev_notice(&state->client->dev, "%s(): Wrong dfu_state (%d) while expected(%d)\n", @@ -4682,8 +4678,8 @@ static const struct file_operations ds5_device_file_ops = { .release = &ds5_dfu_device_release }; -struct class* g_ds5_class; -atomic_t primary_chardev=ATOMIC_INIT(0); +struct class *g_ds5_class; +atomic_t primary_chardev = ATOMIC_INIT(0); static int ds5_chrdev_init(struct i2c_client *c, struct ds5 *state) { @@ -4719,7 +4715,7 @@ static int ds5_chrdev_init(struct i2c_client *c, struct ds5 *state) /* Build up the current device number. To be used further */ *dev_num = MKDEV(MAJOR(*dev_num), MINOR(*dev_num)); /* Create a device node for this device. */ - snprintf (dev_name, sizeof(dev_name), "%s%d", + snprintf(dev_name, sizeof(dev_name), "%s%d", DS5_DRIVER_NAME_DFU, MAJOR(*dev_num)); chr_dev = device_create(*ds5_class, NULL, *dev_num, NULL, dev_name); if (IS_ERR(chr_dev)) { @@ -4769,7 +4765,8 @@ static void ds5_substream_init(void) set_sub_stream_dt(1, MIPI_CSI2_TYPE_EMBEDDED8); set_sub_stream_vc_id(1, 0); /*RGB*/ - set_sub_stream_fmt(2, MEDIA_BUS_FMT_UYVY8_1X16); + + set_sub_stream_fmt(2, MEDIA_BUS_FMT_YUYV8_1X16); set_sub_stream_h(2, 640); set_sub_stream_w(2, 480); set_sub_stream_dt(2, mbus_code_to_mipi(MEDIA_BUS_FMT_UYVY8_1X16));