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

1 // SPDX-License-Identifier: GPL-2.0-only
20 static void po1030_dump_registers(struct sd *sd);
37 {SENSOR, PO1030_AUTOCTRL2, PO1030_SENSOR_RESET | (1 << 2)},
57 {SENSOR, PO1030_AUTOCTRL2, PO1030_SENSOR_RESET | (1 << 2)},
107 /* Set the x window to 1 */
111 /* Set the y window to 1 */
150 .step = 1,
155 int po1030_probe(struct sd *sd) in po1030_probe() argument
159 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in po1030_probe()
168 return -ENODEV; in po1030_probe()
173 /* Run the pre-init to actually probe the unit */ in po1030_probe()
177 err = m5602_write_sensor(sd, preinit_po1030[i][1], in po1030_probe()
178 &data, 1); in po1030_probe()
180 err = m5602_write_bridge(sd, preinit_po1030[i][1], in po1030_probe()
186 if (m5602_read_sensor(sd, PO1030_DEVID_H, &dev_id_h, 1)) in po1030_probe()
187 return -ENODEV; in po1030_probe()
193 return -ENODEV; in po1030_probe()
196 sd->gspca_dev.cam.cam_mode = po1030_modes; in po1030_probe()
197 sd->gspca_dev.cam.nmodes = ARRAY_SIZE(po1030_modes); in po1030_probe()
202 int po1030_init(struct sd *sd) in po1030_init() argument
212 err = m5602_write_bridge(sd, in po1030_init()
213 init_po1030[i][1], in po1030_init()
219 err = m5602_write_sensor(sd, in po1030_init()
220 init_po1030[i][1], data, 1); in po1030_init()
225 return -EINVAL; in po1030_init()
232 po1030_dump_registers(sd); in po1030_init()
237 int po1030_init_controls(struct sd *sd) in po1030_init_controls() argument
239 struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler; in po1030_init_controls()
241 sd->gspca_dev.vdev.ctrl_handler = hdl; in po1030_init_controls()
244 sd->auto_white_bal = v4l2_ctrl_new_std(hdl, &po1030_ctrl_ops, in po1030_init_controls()
246 0, 1, 1, 0); in po1030_init_controls()
247 sd->green_bal = v4l2_ctrl_new_custom(hdl, &po1030_greenbal_cfg, NULL); in po1030_init_controls()
248 sd->red_bal = v4l2_ctrl_new_std(hdl, &po1030_ctrl_ops, in po1030_init_controls()
249 V4L2_CID_RED_BALANCE, 0, 255, 1, in po1030_init_controls()
251 sd->blue_bal = v4l2_ctrl_new_std(hdl, &po1030_ctrl_ops, in po1030_init_controls()
252 V4L2_CID_BLUE_BALANCE, 0, 255, 1, in po1030_init_controls()
255 sd->autoexpo = v4l2_ctrl_new_std_menu(hdl, &po1030_ctrl_ops, in po1030_init_controls()
256 V4L2_CID_EXPOSURE_AUTO, 1, 0, V4L2_EXPOSURE_MANUAL); in po1030_init_controls()
257 sd->expo = v4l2_ctrl_new_std(hdl, &po1030_ctrl_ops, V4L2_CID_EXPOSURE, in po1030_init_controls()
258 0, 0x2ff, 1, PO1030_EXPOSURE_DEFAULT); in po1030_init_controls()
260 sd->gain = v4l2_ctrl_new_std(hdl, &po1030_ctrl_ops, V4L2_CID_GAIN, 0, in po1030_init_controls()
261 0x4f, 1, PO1030_GLOBAL_GAIN_DEFAULT); in po1030_init_controls()
263 sd->hflip = v4l2_ctrl_new_std(hdl, &po1030_ctrl_ops, V4L2_CID_HFLIP, in po1030_init_controls()
264 0, 1, 1, 0); in po1030_init_controls()
265 sd->vflip = v4l2_ctrl_new_std(hdl, &po1030_ctrl_ops, V4L2_CID_VFLIP, in po1030_init_controls()
266 0, 1, 1, 0); in po1030_init_controls()
268 if (hdl->error) { in po1030_init_controls()
270 return hdl->error; in po1030_init_controls()
273 v4l2_ctrl_auto_cluster(4, &sd->auto_white_bal, 0, false); in po1030_init_controls()
274 v4l2_ctrl_auto_cluster(2, &sd->autoexpo, 0, false); in po1030_init_controls()
275 v4l2_ctrl_cluster(2, &sd->hflip); in po1030_init_controls()
280 int po1030_start(struct sd *sd) in po1030_start() argument
282 struct cam *cam = &sd->gspca_dev.cam; in po1030_start()
284 int width = cam->cam_mode[sd->gspca_dev.curr_mode].width; in po1030_start()
285 int height = cam->cam_mode[sd->gspca_dev.curr_mode].height; in po1030_start()
286 int ver_offs = cam->cam_mode[sd->gspca_dev.curr_mode].priv; in po1030_start()
292 err = m5602_write_sensor(sd, PO1030_CONTROL3, &data, 1); in po1030_start()
297 err = m5602_write_sensor(sd, PO1030_WINDOWWIDTH_H, &data, 1); in po1030_start()
302 err = m5602_write_sensor(sd, PO1030_WINDOWWIDTH_L, &data, 1); in po1030_start()
306 data = ((height + 1) >> 8) & 0xff; in po1030_start()
307 err = m5602_write_sensor(sd, PO1030_WINDOWHEIGHT_H, &data, 1); in po1030_start()
311 data = (height + 1) & 0xff; in po1030_start()
312 err = m5602_write_sensor(sd, PO1030_WINDOWHEIGHT_L, &data, 1); in po1030_start()
315 width -= 1; in po1030_start()
320 err = m5602_write_sensor(sd, PO1030_CONTROL3, &data, 1); in po1030_start()
325 err = m5602_write_sensor(sd, PO1030_WINDOWWIDTH_H, &data, 1); in po1030_start()
330 err = m5602_write_sensor(sd, PO1030_WINDOWWIDTH_L, &data, 1); in po1030_start()
335 err = m5602_write_sensor(sd, PO1030_WINDOWHEIGHT_H, &data, 1); in po1030_start()
340 err = m5602_write_sensor(sd, PO1030_WINDOWHEIGHT_L, &data, 1); in po1030_start()
343 width -= 2; in po1030_start()
346 err = m5602_write_bridge(sd, M5602_XB_SENSOR_TYPE, 0x0c); in po1030_start()
350 err = m5602_write_bridge(sd, M5602_XB_LINE_OF_FRAME_H, 0x81); in po1030_start()
354 err = m5602_write_bridge(sd, M5602_XB_PIX_OF_LINE_H, 0x82); in po1030_start()
358 err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0x01); in po1030_start()
362 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, in po1030_start()
367 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (ver_offs & 0xff)); in po1030_start()
372 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0); in po1030_start()
376 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height >> 8) & 0xff); in po1030_start()
380 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height & 0xff)); in po1030_start()
385 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0); in po1030_start()
388 err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0); in po1030_start()
391 err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, 0); in po1030_start()
395 err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, (width >> 8) & 0xff); in po1030_start()
399 err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, (width & 0xff)); in po1030_start()
403 err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0); in po1030_start()
409 struct sd *sd = (struct sd *) gspca_dev; in po1030_set_exposure() local
419 err = m5602_write_sensor(sd, PO1030_INTEGLINES_H, in po1030_set_exposure()
420 &i2c_data, 1); in po1030_set_exposure()
427 err = m5602_write_sensor(sd, PO1030_INTEGLINES_M, in po1030_set_exposure()
428 &i2c_data, 1); in po1030_set_exposure()
435 struct sd *sd = (struct sd *) gspca_dev; in po1030_set_gain() local
441 err = m5602_write_sensor(sd, PO1030_GLOBALGAIN, in po1030_set_gain()
442 &i2c_data, 1); in po1030_set_gain()
448 struct sd *sd = (struct sd *) gspca_dev; in po1030_set_hvflip() local
453 sd->hflip->val, sd->vflip->val); in po1030_set_hvflip()
454 err = m5602_read_sensor(sd, PO1030_CONTROL2, &i2c_data, 1); in po1030_set_hvflip()
458 i2c_data = (0x3f & i2c_data) | (sd->hflip->val << 7) | in po1030_set_hvflip()
459 (sd->vflip->val << 6); in po1030_set_hvflip()
461 err = m5602_write_sensor(sd, PO1030_CONTROL2, in po1030_set_hvflip()
462 &i2c_data, 1); in po1030_set_hvflip()
469 struct sd *sd = (struct sd *) gspca_dev; in po1030_set_red_balance() local
475 err = m5602_write_sensor(sd, PO1030_RED_GAIN, in po1030_set_red_balance()
476 &i2c_data, 1); in po1030_set_red_balance()
482 struct sd *sd = (struct sd *) gspca_dev; in po1030_set_blue_balance() local
488 err = m5602_write_sensor(sd, PO1030_BLUE_GAIN, in po1030_set_blue_balance()
489 &i2c_data, 1); in po1030_set_blue_balance()
496 struct sd *sd = (struct sd *) gspca_dev; in po1030_set_green_balance() local
503 err = m5602_write_sensor(sd, PO1030_GREEN_1_GAIN, in po1030_set_green_balance()
504 &i2c_data, 1); in po1030_set_green_balance()
508 return m5602_write_sensor(sd, PO1030_GREEN_2_GAIN, in po1030_set_green_balance()
509 &i2c_data, 1); in po1030_set_green_balance()
515 struct sd *sd = (struct sd *) gspca_dev; in po1030_set_auto_white_balance() local
519 err = m5602_read_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); in po1030_set_auto_white_balance()
525 err = m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); in po1030_set_auto_white_balance()
532 struct sd *sd = (struct sd *) gspca_dev; in po1030_set_auto_exposure() local
536 err = m5602_read_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); in po1030_set_auto_exposure()
542 i2c_data = (i2c_data & 0xfd) | ((val & 0x01) << 1); in po1030_set_auto_exposure()
543 return m5602_write_sensor(sd, PO1030_AUTOCTRL1, &i2c_data, 1); in po1030_set_auto_exposure()
546 void po1030_disconnect(struct sd *sd) in po1030_disconnect() argument
548 sd->sensor = NULL; in po1030_disconnect()
554 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in po1030_s_ctrl()
555 struct sd *sd = (struct sd *) gspca_dev; in po1030_s_ctrl() local
558 if (!gspca_dev->streaming) in po1030_s_ctrl()
561 switch (ctrl->id) { in po1030_s_ctrl()
563 err = po1030_set_auto_white_balance(gspca_dev, ctrl->val); in po1030_s_ctrl()
564 if (err || ctrl->val) in po1030_s_ctrl()
566 err = po1030_set_green_balance(gspca_dev, sd->green_bal->val); in po1030_s_ctrl()
569 err = po1030_set_red_balance(gspca_dev, sd->red_bal->val); in po1030_s_ctrl()
572 err = po1030_set_blue_balance(gspca_dev, sd->blue_bal->val); in po1030_s_ctrl()
575 err = po1030_set_auto_exposure(gspca_dev, ctrl->val); in po1030_s_ctrl()
576 if (err || ctrl->val == V4L2_EXPOSURE_AUTO) in po1030_s_ctrl()
578 err = po1030_set_exposure(gspca_dev, sd->expo->val); in po1030_s_ctrl()
581 err = po1030_set_gain(gspca_dev, ctrl->val); in po1030_s_ctrl()
587 return -EINVAL; in po1030_s_ctrl()
593 static void po1030_dump_registers(struct sd *sd) in po1030_dump_registers() argument
600 m5602_read_sensor(sd, address, &value, 1); in po1030_dump_registers()
611 m5602_read_sensor(sd, address, &old_value, 1); in po1030_dump_registers()
612 m5602_write_sensor(sd, address, test_value, 1); in po1030_dump_registers()
613 m5602_read_sensor(sd, address, &ctrl_value, 1); in po1030_dump_registers()
621 m5602_write_sensor(sd, address, &old_value, 1); in po1030_dump_registers()