Lines Matching +full:1 +full:- +full:sd

1 // SPDX-License-Identifier: GPL-2.0-only
21 static void ov9650_dump_registers(struct sd *sd);
87 set output Y/UV delay to 1 */
151 /* Enable denoise, and white-pixel erase */
294 int ov9650_probe(struct sd *sd) in ov9650_probe() argument
298 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov9650_probe()
307 return -ENODEV; in ov9650_probe()
312 /* Run the pre-init before probing the sensor */ in ov9650_probe()
316 err = m5602_write_sensor(sd, in ov9650_probe()
317 preinit_ov9650[i][1], &data, 1); in ov9650_probe()
319 err = m5602_write_bridge(sd, in ov9650_probe()
320 preinit_ov9650[i][1], data); in ov9650_probe()
326 if (m5602_read_sensor(sd, OV9650_PID, &prod_id, 1)) in ov9650_probe()
327 return -ENODEV; in ov9650_probe()
329 if (m5602_read_sensor(sd, OV9650_VER, &ver_id, 1)) in ov9650_probe()
330 return -ENODEV; in ov9650_probe()
336 return -ENODEV; in ov9650_probe()
339 sd->gspca_dev.cam.cam_mode = ov9650_modes; in ov9650_probe()
340 sd->gspca_dev.cam.nmodes = ARRAY_SIZE(ov9650_modes); in ov9650_probe()
345 int ov9650_init(struct sd *sd) in ov9650_init() argument
351 ov9650_dump_registers(sd); in ov9650_init()
356 err = m5602_write_sensor(sd, init_ov9650[i][1], in ov9650_init()
357 &data, 1); in ov9650_init()
359 err = m5602_write_bridge(sd, init_ov9650[i][1], data); in ov9650_init()
365 int ov9650_init_controls(struct sd *sd) in ov9650_init_controls() argument
367 struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler; in ov9650_init_controls()
369 sd->gspca_dev.vdev.ctrl_handler = hdl; in ov9650_init_controls()
372 sd->auto_white_bal = v4l2_ctrl_new_std(hdl, &ov9650_ctrl_ops, in ov9650_init_controls()
374 0, 1, 1, 1); in ov9650_init_controls()
375 sd->red_bal = v4l2_ctrl_new_std(hdl, &ov9650_ctrl_ops, in ov9650_init_controls()
376 V4L2_CID_RED_BALANCE, 0, 255, 1, in ov9650_init_controls()
378 sd->blue_bal = v4l2_ctrl_new_std(hdl, &ov9650_ctrl_ops, in ov9650_init_controls()
379 V4L2_CID_BLUE_BALANCE, 0, 255, 1, in ov9650_init_controls()
382 sd->autoexpo = v4l2_ctrl_new_std_menu(hdl, &ov9650_ctrl_ops, in ov9650_init_controls()
383 V4L2_CID_EXPOSURE_AUTO, 1, 0, V4L2_EXPOSURE_AUTO); in ov9650_init_controls()
384 sd->expo = v4l2_ctrl_new_std(hdl, &ov9650_ctrl_ops, V4L2_CID_EXPOSURE, in ov9650_init_controls()
387 sd->autogain = v4l2_ctrl_new_std(hdl, &ov9650_ctrl_ops, in ov9650_init_controls()
388 V4L2_CID_AUTOGAIN, 0, 1, 1, 1); in ov9650_init_controls()
389 sd->gain = v4l2_ctrl_new_std(hdl, &ov9650_ctrl_ops, V4L2_CID_GAIN, 0, in ov9650_init_controls()
390 0x3ff, 1, GAIN_DEFAULT); in ov9650_init_controls()
392 sd->hflip = v4l2_ctrl_new_std(hdl, &ov9650_ctrl_ops, V4L2_CID_HFLIP, in ov9650_init_controls()
393 0, 1, 1, 0); in ov9650_init_controls()
394 sd->vflip = v4l2_ctrl_new_std(hdl, &ov9650_ctrl_ops, V4L2_CID_VFLIP, in ov9650_init_controls()
395 0, 1, 1, 0); in ov9650_init_controls()
397 if (hdl->error) { in ov9650_init_controls()
399 return hdl->error; in ov9650_init_controls()
402 v4l2_ctrl_auto_cluster(3, &sd->auto_white_bal, 0, false); in ov9650_init_controls()
403 v4l2_ctrl_auto_cluster(2, &sd->autoexpo, 0, false); in ov9650_init_controls()
404 v4l2_ctrl_auto_cluster(2, &sd->autogain, 0, false); in ov9650_init_controls()
405 v4l2_ctrl_cluster(2, &sd->hflip); in ov9650_init_controls()
410 int ov9650_start(struct sd *sd) in ov9650_start() argument
414 struct cam *cam = &sd->gspca_dev.cam; in ov9650_start()
416 int width = cam->cam_mode[sd->gspca_dev.curr_mode].width; in ov9650_start()
417 int height = cam->cam_mode[sd->gspca_dev.curr_mode].height; in ov9650_start()
418 int ver_offs = cam->cam_mode[sd->gspca_dev.curr_mode].priv; in ov9650_start()
420 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov9650_start()
423 sd->vflip->val) || in ov9650_start()
425 !sd->vflip->val)) in ov9650_start()
426 ver_offs--; in ov9650_start()
434 err = m5602_write_bridge(sd, res_init_ov9650[i][1], in ov9650_start()
438 err = m5602_write_sensor(sd, in ov9650_start()
439 res_init_ov9650[i][1], &data, 1); in ov9650_start()
445 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, in ov9650_start()
450 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (ver_offs & 0xff)); in ov9650_start()
454 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0); in ov9650_start()
458 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height >> 8) & 0xff); in ov9650_start()
462 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height & 0xff)); in ov9650_start()
467 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0); in ov9650_start()
471 err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0); in ov9650_start()
475 err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 2); in ov9650_start()
479 err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, in ov9650_start()
484 err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, hor_offs & 0xff); in ov9650_start()
488 err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, in ov9650_start()
493 err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, in ov9650_start()
498 err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0); in ov9650_start()
508 err = m5602_write_sensor(sd, OV9650_COM7, &data, 1); in ov9650_start()
516 err = m5602_write_sensor(sd, OV9650_COM7, &data, 1); in ov9650_start()
524 err = m5602_write_sensor(sd, OV9650_COM7, &data, 1); in ov9650_start()
532 err = m5602_write_sensor(sd, OV9650_COM7, &data, 1); in ov9650_start()
538 int ov9650_stop(struct sd *sd) in ov9650_stop() argument
541 return m5602_write_sensor(sd, OV9650_COM2, &data, 1); in ov9650_stop()
544 void ov9650_disconnect(struct sd *sd) in ov9650_disconnect() argument
546 ov9650_stop(sd); in ov9650_disconnect()
548 sd->sensor = NULL; in ov9650_disconnect()
553 struct sd *sd = (struct sd *) gspca_dev; in ov9650_set_exposure() local
561 err = m5602_write_sensor(sd, OV9650_AECHM, in ov9650_set_exposure()
562 &i2c_data, 1); in ov9650_set_exposure()
568 err = m5602_write_sensor(sd, OV9650_AECH, in ov9650_set_exposure()
569 &i2c_data, 1); in ov9650_set_exposure()
575 err = m5602_write_sensor(sd, OV9650_COM1, &i2c_data, 1); in ov9650_set_exposure()
583 struct sd *sd = (struct sd *) gspca_dev; in ov9650_set_gain() local
590 err = m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1); in ov9650_set_gain()
597 err = m5602_write_sensor(sd, OV9650_VREF, &i2c_data, 1); in ov9650_set_gain()
603 err = m5602_write_sensor(sd, OV9650_GAIN, &i2c_data, 1); in ov9650_set_gain()
611 struct sd *sd = (struct sd *) gspca_dev; in ov9650_set_red_balance() local
616 err = m5602_write_sensor(sd, OV9650_RED, &i2c_data, 1); in ov9650_set_red_balance()
624 struct sd *sd = (struct sd *) gspca_dev; in ov9650_set_blue_balance() local
629 err = m5602_write_sensor(sd, OV9650_BLUE, &i2c_data, 1); in ov9650_set_blue_balance()
637 struct sd *sd = (struct sd *) gspca_dev; in ov9650_set_hvflip() local
638 int hflip = sd->hflip->val; in ov9650_set_hvflip()
639 int vflip = sd->vflip->val; in ov9650_set_hvflip()
647 err = m5602_write_sensor(sd, OV9650_MVFP, &i2c_data, 1); in ov9650_set_hvflip()
652 if (gspca_dev->streaming) in ov9650_set_hvflip()
653 err = ov9650_start(sd); in ov9650_set_hvflip()
663 struct sd *sd = (struct sd *) gspca_dev; in ov9650_set_auto_exposure() local
667 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); in ov9650_set_auto_exposure()
674 return m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1); in ov9650_set_auto_exposure()
682 struct sd *sd = (struct sd *) gspca_dev; in ov9650_set_auto_white_balance() local
686 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); in ov9650_set_auto_white_balance()
690 i2c_data = ((i2c_data & 0xfd) | ((val & 0x01) << 1)); in ov9650_set_auto_white_balance()
691 err = m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1); in ov9650_set_auto_white_balance()
700 struct sd *sd = (struct sd *) gspca_dev; in ov9650_set_auto_gain() local
704 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1); in ov9650_set_auto_gain()
710 return m5602_write_sensor(sd, OV9650_COM8, &i2c_data, 1); in ov9650_set_auto_gain()
716 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in ov9650_s_ctrl()
717 struct sd *sd = (struct sd *) gspca_dev; in ov9650_s_ctrl() local
720 if (!gspca_dev->streaming) in ov9650_s_ctrl()
723 switch (ctrl->id) { in ov9650_s_ctrl()
725 err = ov9650_set_auto_white_balance(gspca_dev, ctrl->val); in ov9650_s_ctrl()
726 if (err || ctrl->val) in ov9650_s_ctrl()
728 err = ov9650_set_red_balance(gspca_dev, sd->red_bal->val); in ov9650_s_ctrl()
731 err = ov9650_set_blue_balance(gspca_dev, sd->blue_bal->val); in ov9650_s_ctrl()
734 err = ov9650_set_auto_exposure(gspca_dev, ctrl->val); in ov9650_s_ctrl()
735 if (err || ctrl->val == V4L2_EXPOSURE_AUTO) in ov9650_s_ctrl()
737 err = ov9650_set_exposure(gspca_dev, sd->expo->val); in ov9650_s_ctrl()
740 err = ov9650_set_auto_gain(gspca_dev, ctrl->val); in ov9650_s_ctrl()
741 if (err || ctrl->val) in ov9650_s_ctrl()
743 err = ov9650_set_gain(gspca_dev, sd->gain->val); in ov9650_s_ctrl()
749 return -EINVAL; in ov9650_s_ctrl()
755 static void ov9650_dump_registers(struct sd *sd) in ov9650_dump_registers() argument
761 m5602_read_sensor(sd, address, &value, 1); in ov9650_dump_registers()
772 m5602_read_sensor(sd, address, &old_value, 1); in ov9650_dump_registers()
773 m5602_write_sensor(sd, address, test_value, 1); in ov9650_dump_registers()
774 m5602_read_sensor(sd, address, &ctrl_value, 1); in ov9650_dump_registers()
782 m5602_write_sensor(sd, address, &old_value, 1); in ov9650_dump_registers()