static int s5k83a_s_ctrl(struct v4l2_ctrl *ctrl) { struct gspca_dev *gspca_dev = container_of(ctrl->handler, struct gspca_dev, ctrl_handler); int err; if (!gspca_dev->streaming) return 0; switch (ctrl->id) { case V4L2_CID_BRIGHTNESS: err = s5k83a_set_brightness(gspca_dev, ctrl->val); break; case V4L2_CID_EXPOSURE: err = s5k83a_set_exposure(gspca_dev, ctrl->val); break; case V4L2_CID_GAIN: err = s5k83a_set_gain(gspca_dev, ctrl->val); break; case V4L2_CID_HFLIP: err = s5k83a_set_hvflip(gspca_dev); break; default: return -EINVAL; } return err; }
int s5k83a_init(struct sd *sd) { int i, err = 0; s32 *sensor_settings = ((struct s5k83a_priv *) sd->sensor_priv)->settings; for (i = 0; i < ARRAY_SIZE(init_s5k83a) && !err; i++) { u8 data[2] = {0x00, 0x00}; switch (init_s5k83a[i][0]) { case BRIDGE: err = m5602_write_bridge(sd, init_s5k83a[i][1], init_s5k83a[i][2]); break; case SENSOR: data[0] = init_s5k83a[i][2]; err = m5602_write_sensor(sd, init_s5k83a[i][1], data, 1); break; case SENSOR_LONG: data[0] = init_s5k83a[i][2]; data[1] = init_s5k83a[i][3]; err = m5602_write_sensor(sd, init_s5k83a[i][1], data, 2); break; default: info("Invalid stream command, exiting init"); return -EINVAL; } } if (dump_sensor) s5k83a_dump_registers(sd); err = s5k83a_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]); if (err < 0) return err; err = s5k83a_set_brightness(&sd->gspca_dev, sensor_settings[BRIGHTNESS_IDX]); if (err < 0) return err; err = s5k83a_set_exposure(&sd->gspca_dev, sensor_settings[EXPOSURE_IDX]); if (err < 0) return err; err = s5k83a_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]); if (err < 0) return err; err = s5k83a_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]); return err; }