Lines Matching refs:sd
212 struct v4l2_subdev sd; member
240 static inline struct ov7670_info *to_state(struct v4l2_subdev *sd) in to_state() argument
242 return container_of(sd, struct ov7670_info, sd); in to_state()
247 return &container_of(ctrl->handler, struct ov7670_info, hdl)->sd; in to_sd()
459 static int ov7670_read_smbus(struct v4l2_subdev *sd, unsigned char reg, in ov7670_read_smbus() argument
462 struct i2c_client *client = v4l2_get_subdevdata(sd); in ov7670_read_smbus()
474 static int ov7670_write_smbus(struct v4l2_subdev *sd, unsigned char reg, in ov7670_write_smbus() argument
477 struct i2c_client *client = v4l2_get_subdevdata(sd); in ov7670_write_smbus()
488 static int ov7670_read_i2c(struct v4l2_subdev *sd, unsigned char reg, in ov7670_read_i2c() argument
491 struct i2c_client *client = v4l2_get_subdevdata(sd); in ov7670_read_i2c()
521 static int ov7670_write_i2c(struct v4l2_subdev *sd, unsigned char reg, in ov7670_write_i2c() argument
524 struct i2c_client *client = v4l2_get_subdevdata(sd); in ov7670_write_i2c()
541 static int ov7670_read(struct v4l2_subdev *sd, unsigned char reg, in ov7670_read() argument
544 struct ov7670_info *info = to_state(sd); in ov7670_read()
546 return ov7670_read_smbus(sd, reg, value); in ov7670_read()
548 return ov7670_read_i2c(sd, reg, value); in ov7670_read()
551 static int ov7670_write(struct v4l2_subdev *sd, unsigned char reg, in ov7670_write() argument
554 struct ov7670_info *info = to_state(sd); in ov7670_write()
556 return ov7670_write_smbus(sd, reg, value); in ov7670_write()
558 return ov7670_write_i2c(sd, reg, value); in ov7670_write()
564 static int ov7670_write_array(struct v4l2_subdev *sd, struct regval_list *vals) in ov7670_write_array() argument
567 int ret = ov7670_write(sd, vals->reg_num, vals->value); in ov7670_write_array()
579 static int ov7670_reset(struct v4l2_subdev *sd, u32 val) in ov7670_reset() argument
581 ov7670_write(sd, REG_COM7, COM7_RESET); in ov7670_reset()
587 static int ov7670_init(struct v4l2_subdev *sd, u32 val) in ov7670_init() argument
589 return ov7670_write_array(sd, ov7670_default_regs); in ov7670_init()
594 static int ov7670_detect(struct v4l2_subdev *sd) in ov7670_detect() argument
599 ret = ov7670_init(sd, 0); in ov7670_detect()
602 ret = ov7670_read(sd, REG_MIDH, &v); in ov7670_detect()
607 ret = ov7670_read(sd, REG_MIDL, &v); in ov7670_detect()
615 ret = ov7670_read(sd, REG_PID, &v); in ov7670_detect()
620 ret = ov7670_read(sd, REG_VER, &v); in ov7670_detect()
762 static void ov7675_get_framerate(struct v4l2_subdev *sd, in ov7675_get_framerate() argument
765 struct ov7670_info *info = to_state(sd); in ov7675_get_framerate()
783 static int ov7675_set_framerate(struct v4l2_subdev *sd, in ov7675_set_framerate() argument
786 struct ov7670_info *info = to_state(sd); in ov7675_set_framerate()
800 ret = ov7670_write(sd, REG_DBLV, DBLV_BYPASS); in ov7675_set_framerate()
803 ret = ov7670_write(sd, REG_DBLV, DBLV_X4); in ov7675_set_framerate()
830 ov7675_get_framerate(sd, tpf); in ov7675_set_framerate()
832 ret = ov7670_write(sd, REG_CLKRC, info->clkrc); in ov7675_set_framerate()
836 return ov7670_write(sd, REG_DBLV, DBLV_X4); in ov7675_set_framerate()
839 static void ov7670_get_framerate_legacy(struct v4l2_subdev *sd, in ov7670_get_framerate_legacy() argument
842 struct ov7670_info *info = to_state(sd); in ov7670_get_framerate_legacy()
850 static int ov7670_set_framerate_legacy(struct v4l2_subdev *sd, in ov7670_set_framerate_legacy() argument
853 struct ov7670_info *info = to_state(sd); in ov7670_set_framerate_legacy()
867 return ov7670_write(sd, REG_CLKRC, info->clkrc); in ov7670_set_framerate_legacy()
873 static int ov7670_set_hw(struct v4l2_subdev *sd, int hstart, int hstop, in ov7670_set_hw() argument
883 ret = ov7670_write(sd, REG_HSTART, (hstart >> 3) & 0xff); in ov7670_set_hw()
884 ret += ov7670_write(sd, REG_HSTOP, (hstop >> 3) & 0xff); in ov7670_set_hw()
885 ret += ov7670_read(sd, REG_HREF, &v); in ov7670_set_hw()
888 ret += ov7670_write(sd, REG_HREF, v); in ov7670_set_hw()
892 ret += ov7670_write(sd, REG_VSTART, (vstart >> 2) & 0xff); in ov7670_set_hw()
893 ret += ov7670_write(sd, REG_VSTOP, (vstop >> 2) & 0xff); in ov7670_set_hw()
894 ret += ov7670_read(sd, REG_VREF, &v); in ov7670_set_hw()
897 ret += ov7670_write(sd, REG_VREF, v); in ov7670_set_hw()
902 static int ov7670_enum_mbus_code(struct v4l2_subdev *sd, in ov7670_enum_mbus_code() argument
913 static int ov7670_try_fmt_internal(struct v4l2_subdev *sd, in ov7670_try_fmt_internal() argument
920 struct ov7670_info *info = to_state(sd); in ov7670_try_fmt_internal()
977 static int ov7670_set_fmt(struct v4l2_subdev *sd, in ov7670_set_fmt() argument
983 struct ov7670_info *info = to_state(sd); in ov7670_set_fmt()
991 ret = ov7670_try_fmt_internal(sd, &format->format, NULL, NULL); in ov7670_set_fmt()
998 ret = ov7670_try_fmt_internal(sd, &format->format, &ovfmt, &wsize); in ov7670_set_fmt()
1010 ov7670_write(sd, REG_COM7, com7); in ov7670_set_fmt()
1014 ov7670_write_array(sd, ovfmt->regs + 1); in ov7670_set_fmt()
1015 ov7670_set_hw(sd, wsize->hstart, wsize->hstop, wsize->vstart, in ov7670_set_fmt()
1019 ret = ov7670_write_array(sd, wsize->regs); in ov7670_set_fmt()
1033 ret = ov7670_write(sd, REG_CLKRC, info->clkrc); in ov7670_set_fmt()
1041 static int ov7670_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms) in ov7670_g_parm() argument
1044 struct ov7670_info *info = to_state(sd); in ov7670_g_parm()
1051 info->devtype->get_framerate(sd, &cp->timeperframe); in ov7670_g_parm()
1056 static int ov7670_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms) in ov7670_s_parm() argument
1060 struct ov7670_info *info = to_state(sd); in ov7670_s_parm()
1067 return info->devtype->set_framerate(sd, tpf); in ov7670_s_parm()
1079 static int ov7670_enum_frame_interval(struct v4l2_subdev *sd, in ov7670_enum_frame_interval() argument
1083 struct ov7670_info *info = to_state(sd); in ov7670_enum_frame_interval()
1118 static int ov7670_enum_frame_size(struct v4l2_subdev *sd, in ov7670_enum_frame_size() argument
1122 struct ov7670_info *info = to_state(sd); in ov7670_enum_frame_size()
1155 static int ov7670_store_cmatrix(struct v4l2_subdev *sd, in ov7670_store_cmatrix() argument
1165 ret = ov7670_read(sd, REG_CMATRIX_SIGN, &signbits); in ov7670_store_cmatrix()
1184 ret += ov7670_write(sd, REG_CMATRIX_BASE + i, raw); in ov7670_store_cmatrix()
1186 ret += ov7670_write(sd, REG_CMATRIX_SIGN, signbits); in ov7670_store_cmatrix()
1269 static int ov7670_s_sat_hue(struct v4l2_subdev *sd, int sat, int hue) in ov7670_s_sat_hue() argument
1271 struct ov7670_info *info = to_state(sd); in ov7670_s_sat_hue()
1276 ret = ov7670_store_cmatrix(sd, matrix); in ov7670_s_sat_hue()
1292 static int ov7670_s_brightness(struct v4l2_subdev *sd, int value) in ov7670_s_brightness() argument
1297 ov7670_read(sd, REG_COM8, &com8); in ov7670_s_brightness()
1299 ov7670_write(sd, REG_COM8, com8); in ov7670_s_brightness()
1301 ret = ov7670_write(sd, REG_BRIGHT, v); in ov7670_s_brightness()
1305 static int ov7670_s_contrast(struct v4l2_subdev *sd, int value) in ov7670_s_contrast() argument
1307 return ov7670_write(sd, REG_CONTRAS, (unsigned char) value); in ov7670_s_contrast()
1310 static int ov7670_s_hflip(struct v4l2_subdev *sd, int value) in ov7670_s_hflip() argument
1315 ret = ov7670_read(sd, REG_MVFP, &v); in ov7670_s_hflip()
1321 ret += ov7670_write(sd, REG_MVFP, v); in ov7670_s_hflip()
1325 static int ov7670_s_vflip(struct v4l2_subdev *sd, int value) in ov7670_s_vflip() argument
1330 ret = ov7670_read(sd, REG_MVFP, &v); in ov7670_s_vflip()
1336 ret += ov7670_write(sd, REG_MVFP, v); in ov7670_s_vflip()
1346 static int ov7670_g_gain(struct v4l2_subdev *sd, __s32 *value) in ov7670_g_gain() argument
1351 ret = ov7670_read(sd, REG_GAIN, &gain); in ov7670_g_gain()
1356 static int ov7670_s_gain(struct v4l2_subdev *sd, int value) in ov7670_s_gain() argument
1361 ret = ov7670_write(sd, REG_GAIN, value & 0xff); in ov7670_s_gain()
1364 ret = ov7670_read(sd, REG_COM8, &com8); in ov7670_s_gain()
1365 ret = ov7670_write(sd, REG_COM8, com8 & ~COM8_AGC); in ov7670_s_gain()
1373 static int ov7670_s_autogain(struct v4l2_subdev *sd, int value) in ov7670_s_autogain() argument
1378 ret = ov7670_read(sd, REG_COM8, &com8); in ov7670_s_autogain()
1384 ret = ov7670_write(sd, REG_COM8, com8); in ov7670_s_autogain()
1389 static int ov7670_s_exp(struct v4l2_subdev *sd, int value) in ov7670_s_exp() argument
1394 ret = ov7670_read(sd, REG_COM1, &com1) + in ov7670_s_exp()
1395 ov7670_read(sd, REG_COM8, &com8) + in ov7670_s_exp()
1396 ov7670_read(sd, REG_AECHH, &aechh); in ov7670_s_exp()
1403 ret = ov7670_write(sd, REG_COM1, com1) + in ov7670_s_exp()
1404 ov7670_write(sd, REG_AECH, aech) + in ov7670_s_exp()
1405 ov7670_write(sd, REG_AECHH, aechh); in ov7670_s_exp()
1408 ret = ov7670_write(sd, REG_COM8, com8 & ~COM8_AEC); in ov7670_s_exp()
1415 static int ov7670_s_autoexp(struct v4l2_subdev *sd, in ov7670_s_autoexp() argument
1421 ret = ov7670_read(sd, REG_COM8, &com8); in ov7670_s_autoexp()
1427 ret = ov7670_write(sd, REG_COM8, com8); in ov7670_s_autoexp()
1435 struct v4l2_subdev *sd = to_sd(ctrl); in ov7670_g_volatile_ctrl() local
1436 struct ov7670_info *info = to_state(sd); in ov7670_g_volatile_ctrl()
1440 return ov7670_g_gain(sd, &info->gain->val); in ov7670_g_volatile_ctrl()
1447 struct v4l2_subdev *sd = to_sd(ctrl); in ov7670_s_ctrl() local
1448 struct ov7670_info *info = to_state(sd); in ov7670_s_ctrl()
1452 return ov7670_s_brightness(sd, ctrl->val); in ov7670_s_ctrl()
1454 return ov7670_s_contrast(sd, ctrl->val); in ov7670_s_ctrl()
1456 return ov7670_s_sat_hue(sd, in ov7670_s_ctrl()
1459 return ov7670_s_vflip(sd, ctrl->val); in ov7670_s_ctrl()
1461 return ov7670_s_hflip(sd, ctrl->val); in ov7670_s_ctrl()
1467 return ov7670_s_gain(sd, info->gain->val); in ov7670_s_ctrl()
1469 return ov7670_s_autogain(sd, ctrl->val); in ov7670_s_ctrl()
1475 return ov7670_s_exp(sd, info->exposure->val); in ov7670_s_ctrl()
1477 return ov7670_s_autoexp(sd, ctrl->val); in ov7670_s_ctrl()
1488 static int ov7670_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) in ov7670_g_register() argument
1493 ret = ov7670_read(sd, reg->reg & 0xff, &val); in ov7670_g_register()
1499 static int ov7670_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) in ov7670_s_register() argument
1501 ov7670_write(sd, reg->reg & 0xff, reg->val & 0xff); in ov7670_s_register()
1556 struct v4l2_subdev *sd; in ov7670_probe() local
1563 sd = &info->sd; in ov7670_probe()
1564 v4l2_i2c_subdev_init(sd, client, &ov7670_ops); in ov7670_probe()
1593 ret = ov7670_detect(sd); in ov7670_probe()
1610 info->devtype->set_framerate(sd, &tpf); in ov7670_probe()
1613 ov7670_write(sd, REG_COM10, COM10_PCLK_HB); in ov7670_probe()
1637 sd->ctrl_handler = &info->hdl; in ov7670_probe()
1660 struct v4l2_subdev *sd = i2c_get_clientdata(client); in ov7670_remove() local
1661 struct ov7670_info *info = to_state(sd); in ov7670_remove()
1663 v4l2_device_unregister_subdev(sd); in ov7670_remove()