Lines Matching +full:1 +full:- +full:sd
1 // SPDX-License-Identifier: GPL-2.0-only
20 static void mt9m111_dump_registers(struct sd *sd);
190 .step = 1,
195 int mt9m111_probe(struct sd *sd) in mt9m111_probe() argument
199 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in mt9m111_probe()
208 return -ENODEV; in mt9m111_probe()
216 err = m5602_write_bridge(sd, in mt9m111_probe()
217 preinit_mt9m111[i][1], in mt9m111_probe()
221 data[1] = preinit_mt9m111[i][3]; in mt9m111_probe()
222 err = m5602_write_sensor(sd, in mt9m111_probe()
223 preinit_mt9m111[i][1], data, 2); in mt9m111_probe()
229 if (m5602_read_sensor(sd, MT9M111_SC_CHIPVER, data, 2)) in mt9m111_probe()
230 return -ENODEV; in mt9m111_probe()
232 if ((data[0] == 0x14) && (data[1] == 0x3a)) { in mt9m111_probe()
237 return -ENODEV; in mt9m111_probe()
240 sd->gspca_dev.cam.cam_mode = mt9m111_modes; in mt9m111_probe()
241 sd->gspca_dev.cam.nmodes = ARRAY_SIZE(mt9m111_modes); in mt9m111_probe()
246 int mt9m111_init(struct sd *sd) in mt9m111_init() argument
255 err = m5602_write_bridge(sd, in mt9m111_init()
256 init_mt9m111[i][1], in mt9m111_init()
260 data[1] = init_mt9m111[i][3]; in mt9m111_init()
261 err = m5602_write_sensor(sd, in mt9m111_init()
262 init_mt9m111[i][1], data, 2); in mt9m111_init()
267 mt9m111_dump_registers(sd); in mt9m111_init()
272 int mt9m111_init_controls(struct sd *sd) in mt9m111_init_controls() argument
274 struct v4l2_ctrl_handler *hdl = &sd->gspca_dev.ctrl_handler; in mt9m111_init_controls()
276 sd->gspca_dev.vdev.ctrl_handler = hdl; in mt9m111_init_controls()
279 sd->auto_white_bal = v4l2_ctrl_new_std(hdl, &mt9m111_ctrl_ops, in mt9m111_init_controls()
281 0, 1, 1, 0); in mt9m111_init_controls()
282 sd->green_bal = v4l2_ctrl_new_custom(hdl, &mt9m111_greenbal_cfg, NULL); in mt9m111_init_controls()
283 sd->red_bal = v4l2_ctrl_new_std(hdl, &mt9m111_ctrl_ops, in mt9m111_init_controls()
284 V4L2_CID_RED_BALANCE, 0, 0x7ff, 1, in mt9m111_init_controls()
286 sd->blue_bal = v4l2_ctrl_new_std(hdl, &mt9m111_ctrl_ops, in mt9m111_init_controls()
287 V4L2_CID_BLUE_BALANCE, 0, 0x7ff, 1, in mt9m111_init_controls()
291 (INITIAL_MAX_GAIN - 1) * 2 * 2 * 2, 1, in mt9m111_init_controls()
294 sd->hflip = v4l2_ctrl_new_std(hdl, &mt9m111_ctrl_ops, V4L2_CID_HFLIP, in mt9m111_init_controls()
295 0, 1, 1, 0); in mt9m111_init_controls()
296 sd->vflip = v4l2_ctrl_new_std(hdl, &mt9m111_ctrl_ops, V4L2_CID_VFLIP, in mt9m111_init_controls()
297 0, 1, 1, 0); in mt9m111_init_controls()
299 if (hdl->error) { in mt9m111_init_controls()
301 return hdl->error; in mt9m111_init_controls()
304 v4l2_ctrl_auto_cluster(4, &sd->auto_white_bal, 0, false); in mt9m111_init_controls()
305 v4l2_ctrl_cluster(2, &sd->hflip); in mt9m111_init_controls()
310 int mt9m111_start(struct sd *sd) in mt9m111_start() argument
314 struct cam *cam = &sd->gspca_dev.cam; in mt9m111_start()
315 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in mt9m111_start()
317 int width = cam->cam_mode[sd->gspca_dev.curr_mode].width - 1; in mt9m111_start()
318 int height = cam->cam_mode[sd->gspca_dev.curr_mode].height; in mt9m111_start()
322 err = m5602_write_bridge(sd, in mt9m111_start()
323 start_mt9m111[i][1], in mt9m111_start()
327 data[1] = start_mt9m111[i][3]; in mt9m111_start()
328 err = m5602_write_sensor(sd, in mt9m111_start()
329 start_mt9m111[i][1], data, 2); in mt9m111_start()
335 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height >> 8) & 0xff); in mt9m111_start()
339 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, (height & 0xff)); in mt9m111_start()
344 err = m5602_write_bridge(sd, M5602_XB_VSYNC_PARA, 0); in mt9m111_start()
348 err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0); in mt9m111_start()
352 err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 2); in mt9m111_start()
357 err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, 0); in mt9m111_start()
361 err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, in mt9m111_start()
366 err = m5602_write_bridge(sd, M5602_XB_HSYNC_PARA, width & 0xff); in mt9m111_start()
370 err = m5602_write_bridge(sd, M5602_XB_SIG_INI, 0); in mt9m111_start()
386 void mt9m111_disconnect(struct sd *sd) in mt9m111_disconnect() argument
388 sd->sensor = NULL; in mt9m111_disconnect()
395 struct sd *sd = (struct sd *) gspca_dev; in mt9m111_set_hvflip() local
400 sd->hflip->val, sd->vflip->val); in mt9m111_set_hvflip()
403 hflip = !sd->hflip->val; in mt9m111_set_hvflip()
404 vflip = !sd->vflip->val; in mt9m111_set_hvflip()
407 err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); in mt9m111_set_hvflip()
412 if (gspca_dev->pixfmt.width == 640) { in mt9m111_set_hvflip()
413 data[1] = MT9M111_RMB_ROW_SKIP_2X | in mt9m111_set_hvflip()
415 (hflip << 1) | vflip; in mt9m111_set_hvflip()
417 data[1] = MT9M111_RMB_ROW_SKIP_4X | in mt9m111_set_hvflip()
419 (hflip << 1) | vflip; in mt9m111_set_hvflip()
421 err = m5602_write_sensor(sd, MT9M111_SC_R_MODE_CONTEXT_B, in mt9m111_set_hvflip()
429 struct sd *sd = (struct sd *) gspca_dev; in mt9m111_set_auto_white_balance() local
433 err = m5602_read_sensor(sd, MT9M111_CP_OPERATING_MODE_CTL, data, 2); in mt9m111_set_auto_white_balance()
437 data[1] = ((data[1] & 0xfd) | ((val & 0x01) << 1)); in mt9m111_set_auto_white_balance()
439 err = m5602_write_sensor(sd, MT9M111_CP_OPERATING_MODE_CTL, data, 2); in mt9m111_set_auto_white_balance()
449 struct sd *sd = (struct sd *) gspca_dev; in mt9m111_set_gain() local
452 err = m5602_write_sensor(sd, MT9M111_PAGE_MAP, data, 2); in mt9m111_set_gain()
457 return -EINVAL; in mt9m111_set_gain()
460 (val < (INITIAL_MAX_GAIN - 1) * 2 * 2 * 2)) in mt9m111_set_gain()
461 tmp = (1 << 10) | (val << 9) | in mt9m111_set_gain()
465 tmp = (1 << 9) | (1 << 8) | (val / 4); in mt9m111_set_gain()
468 tmp = (1 << 8) | (val / 2); in mt9m111_set_gain()
472 data[1] = (tmp & 0xff); in mt9m111_set_gain()
474 gspca_dbg(gspca_dev, D_CONF, "tmp=%d, data[1]=%d, data[0]=%d\n", tmp, in mt9m111_set_gain()
475 data[1], data[0]); in mt9m111_set_gain()
477 err = m5602_write_sensor(sd, MT9M111_SC_GLOBAL_GAIN, in mt9m111_set_gain()
487 struct sd *sd = (struct sd *) gspca_dev; in mt9m111_set_green_balance() local
489 data[1] = (val & 0xff); in mt9m111_set_green_balance()
493 err = m5602_write_sensor(sd, MT9M111_SC_GREEN_1_GAIN, in mt9m111_set_green_balance()
498 return m5602_write_sensor(sd, MT9M111_SC_GREEN_2_GAIN, in mt9m111_set_green_balance()
505 struct sd *sd = (struct sd *) gspca_dev; in mt9m111_set_blue_balance() local
507 data[1] = (val & 0xff); in mt9m111_set_blue_balance()
512 return m5602_write_sensor(sd, MT9M111_SC_BLUE_GAIN, in mt9m111_set_blue_balance()
519 struct sd *sd = (struct sd *) gspca_dev; in mt9m111_set_red_balance() local
521 data[1] = (val & 0xff); in mt9m111_set_red_balance()
526 return m5602_write_sensor(sd, MT9M111_SC_RED_GAIN, in mt9m111_set_red_balance()
533 container_of(ctrl->handler, struct gspca_dev, ctrl_handler); in mt9m111_s_ctrl()
534 struct sd *sd = (struct sd *) gspca_dev; in mt9m111_s_ctrl() local
537 if (!gspca_dev->streaming) in mt9m111_s_ctrl()
540 switch (ctrl->id) { in mt9m111_s_ctrl()
542 err = mt9m111_set_auto_white_balance(gspca_dev, ctrl->val); in mt9m111_s_ctrl()
543 if (err || ctrl->val) in mt9m111_s_ctrl()
545 err = mt9m111_set_green_balance(gspca_dev, sd->green_bal->val); in mt9m111_s_ctrl()
548 err = mt9m111_set_red_balance(gspca_dev, sd->red_bal->val); in mt9m111_s_ctrl()
551 err = mt9m111_set_blue_balance(gspca_dev, sd->blue_bal->val); in mt9m111_s_ctrl()
554 err = mt9m111_set_gain(gspca_dev, ctrl->val); in mt9m111_s_ctrl()
560 return -EINVAL; in mt9m111_s_ctrl()
566 static void mt9m111_dump_registers(struct sd *sd) in mt9m111_dump_registers() argument
573 value[1] = MT9M111_SENSOR_CORE; in mt9m111_dump_registers()
574 m5602_write_sensor(sd, MT9M111_PAGE_MAP, value, 2); in mt9m111_dump_registers()
576 m5602_read_sensor(sd, address, value, 2); in mt9m111_dump_registers()
578 address, value[0], value[1]); in mt9m111_dump_registers()
582 value[1] = MT9M111_COLORPIPE; in mt9m111_dump_registers()
583 m5602_write_sensor(sd, MT9M111_PAGE_MAP, value, 2); in mt9m111_dump_registers()
585 m5602_read_sensor(sd, address, value, 2); in mt9m111_dump_registers()
587 address, value[0], value[1]); in mt9m111_dump_registers()
591 value[1] = MT9M111_CAMERA_CONTROL; in mt9m111_dump_registers()
592 m5602_write_sensor(sd, MT9M111_PAGE_MAP, value, 2); in mt9m111_dump_registers()
594 m5602_read_sensor(sd, address, value, 2); in mt9m111_dump_registers()
596 address, value[0], value[1]); in mt9m111_dump_registers()