예제 #1
0
static int mt9m111_s_ctrl(struct v4l2_ctrl *ctrl)
{
	struct gspca_dev *gspca_dev =
		container_of(ctrl->handler, struct gspca_dev, ctrl_handler);
	struct sd *sd = (struct sd *) gspca_dev;
	int err;

	if (!gspca_dev->streaming)
		return 0;

	switch (ctrl->id) {
	case V4L2_CID_AUTO_WHITE_BALANCE:
		err = mt9m111_set_auto_white_balance(gspca_dev, ctrl->val);
		if (err || ctrl->val)
			return err;
		err = mt9m111_set_green_balance(gspca_dev, sd->green_bal->val);
		if (err)
			return err;
		err = mt9m111_set_red_balance(gspca_dev, sd->red_bal->val);
		if (err)
			return err;
		err = mt9m111_set_blue_balance(gspca_dev, sd->blue_bal->val);
		break;
	case V4L2_CID_GAIN:
		err = mt9m111_set_gain(gspca_dev, ctrl->val);
		break;
	case V4L2_CID_HFLIP:
		err = mt9m111_set_hvflip(gspca_dev);
		break;
	default:
		return -EINVAL;
	}

	return err;
}
예제 #2
0
int mt9m111_init(struct sd *sd)
{
	int i, err = 0;
	s32 *sensor_settings = sd->sensor_priv;

	/* Init the sensor */
	for (i = 0; i < ARRAY_SIZE(init_mt9m111) && !err; i++) {
		u8 data[2];

		if (init_mt9m111[i][0] == BRIDGE) {
			err = m5602_write_bridge(sd,
				init_mt9m111[i][1],
				init_mt9m111[i][2]);
		} else {
			data[0] = init_mt9m111[i][2];
			data[1] = init_mt9m111[i][3];
			err = m5602_write_sensor(sd,
				init_mt9m111[i][1], data, 2);
		}
	}

	if (dump_sensor)
		mt9m111_dump_registers(sd);

	err = mt9m111_set_vflip(&sd->gspca_dev, sensor_settings[VFLIP_IDX]);
	if (err < 0)
		return err;

	err = mt9m111_set_hflip(&sd->gspca_dev, sensor_settings[HFLIP_IDX]);
	if (err < 0)
		return err;

	err = mt9m111_set_green_balance(&sd->gspca_dev,
					 sensor_settings[GREEN_BALANCE_IDX]);
	if (err < 0)
		return err;

	err = mt9m111_set_blue_balance(&sd->gspca_dev,
					 sensor_settings[BLUE_BALANCE_IDX]);
	if (err < 0)
		return err;

	err = mt9m111_set_red_balance(&sd->gspca_dev,
					sensor_settings[RED_BALANCE_IDX]);
	if (err < 0)
		return err;

	return mt9m111_set_gain(&sd->gspca_dev, sensor_settings[GAIN_IDX]);
}