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_fmt(struct v4l2_subdev *sd, unsigned index, in ov7670_enum_mbus_fmt() argument
912 static int ov7670_try_fmt_internal(struct v4l2_subdev *sd, in ov7670_try_fmt_internal() argument
919 struct ov7670_info *info = to_state(sd); in ov7670_try_fmt_internal()
973 static int ov7670_try_mbus_fmt(struct v4l2_subdev *sd, in ov7670_try_mbus_fmt() argument
976 return ov7670_try_fmt_internal(sd, fmt, NULL, NULL); in ov7670_try_mbus_fmt()
982 static int ov7670_s_mbus_fmt(struct v4l2_subdev *sd, in ov7670_s_mbus_fmt() argument
987 struct ov7670_info *info = to_state(sd); in ov7670_s_mbus_fmt()
991 ret = ov7670_try_fmt_internal(sd, fmt, &ovfmt, &wsize); in ov7670_s_mbus_fmt()
1003 ov7670_write(sd, REG_COM7, com7); in ov7670_s_mbus_fmt()
1007 ov7670_write_array(sd, ovfmt->regs + 1); in ov7670_s_mbus_fmt()
1008 ov7670_set_hw(sd, wsize->hstart, wsize->hstop, wsize->vstart, in ov7670_s_mbus_fmt()
1012 ret = ov7670_write_array(sd, wsize->regs); in ov7670_s_mbus_fmt()
1026 ret = ov7670_write(sd, REG_CLKRC, info->clkrc); in ov7670_s_mbus_fmt()
1034 static int ov7670_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms) in ov7670_g_parm() argument
1037 struct ov7670_info *info = to_state(sd); in ov7670_g_parm()
1044 info->devtype->get_framerate(sd, &cp->timeperframe); in ov7670_g_parm()
1049 static int ov7670_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms) in ov7670_s_parm() argument
1053 struct ov7670_info *info = to_state(sd); in ov7670_s_parm()
1060 return info->devtype->set_framerate(sd, tpf); in ov7670_s_parm()
1072 static int ov7670_enum_frame_interval(struct v4l2_subdev *sd, in ov7670_enum_frame_interval() argument
1088 static int ov7670_enum_frame_size(struct v4l2_subdev *sd, in ov7670_enum_frame_size() argument
1092 struct ov7670_info *info = to_state(sd); in ov7670_enum_frame_size()
1125 static int ov7670_store_cmatrix(struct v4l2_subdev *sd, in ov7670_store_cmatrix() argument
1135 ret = ov7670_read(sd, REG_CMATRIX_SIGN, &signbits); in ov7670_store_cmatrix()
1154 ret += ov7670_write(sd, REG_CMATRIX_BASE + i, raw); in ov7670_store_cmatrix()
1156 ret += ov7670_write(sd, REG_CMATRIX_SIGN, signbits); in ov7670_store_cmatrix()
1239 static int ov7670_s_sat_hue(struct v4l2_subdev *sd, int sat, int hue) in ov7670_s_sat_hue() argument
1241 struct ov7670_info *info = to_state(sd); in ov7670_s_sat_hue()
1246 ret = ov7670_store_cmatrix(sd, matrix); in ov7670_s_sat_hue()
1262 static int ov7670_s_brightness(struct v4l2_subdev *sd, int value) in ov7670_s_brightness() argument
1267 ov7670_read(sd, REG_COM8, &com8); in ov7670_s_brightness()
1269 ov7670_write(sd, REG_COM8, com8); in ov7670_s_brightness()
1271 ret = ov7670_write(sd, REG_BRIGHT, v); in ov7670_s_brightness()
1275 static int ov7670_s_contrast(struct v4l2_subdev *sd, int value) in ov7670_s_contrast() argument
1277 return ov7670_write(sd, REG_CONTRAS, (unsigned char) value); in ov7670_s_contrast()
1280 static int ov7670_s_hflip(struct v4l2_subdev *sd, int value) in ov7670_s_hflip() argument
1285 ret = ov7670_read(sd, REG_MVFP, &v); in ov7670_s_hflip()
1291 ret += ov7670_write(sd, REG_MVFP, v); in ov7670_s_hflip()
1295 static int ov7670_s_vflip(struct v4l2_subdev *sd, int value) in ov7670_s_vflip() argument
1300 ret = ov7670_read(sd, REG_MVFP, &v); in ov7670_s_vflip()
1306 ret += ov7670_write(sd, REG_MVFP, v); in ov7670_s_vflip()
1316 static int ov7670_g_gain(struct v4l2_subdev *sd, __s32 *value) in ov7670_g_gain() argument
1321 ret = ov7670_read(sd, REG_GAIN, &gain); in ov7670_g_gain()
1326 static int ov7670_s_gain(struct v4l2_subdev *sd, int value) in ov7670_s_gain() argument
1331 ret = ov7670_write(sd, REG_GAIN, value & 0xff); in ov7670_s_gain()
1334 ret = ov7670_read(sd, REG_COM8, &com8); in ov7670_s_gain()
1335 ret = ov7670_write(sd, REG_COM8, com8 & ~COM8_AGC); in ov7670_s_gain()
1343 static int ov7670_s_autogain(struct v4l2_subdev *sd, int value) in ov7670_s_autogain() argument
1348 ret = ov7670_read(sd, REG_COM8, &com8); in ov7670_s_autogain()
1354 ret = ov7670_write(sd, REG_COM8, com8); in ov7670_s_autogain()
1359 static int ov7670_s_exp(struct v4l2_subdev *sd, int value) in ov7670_s_exp() argument
1364 ret = ov7670_read(sd, REG_COM1, &com1) + in ov7670_s_exp()
1365 ov7670_read(sd, REG_COM8, &com8); in ov7670_s_exp()
1366 ov7670_read(sd, REG_AECHH, &aechh); in ov7670_s_exp()
1373 ret = ov7670_write(sd, REG_COM1, com1) + in ov7670_s_exp()
1374 ov7670_write(sd, REG_AECH, aech) + in ov7670_s_exp()
1375 ov7670_write(sd, REG_AECHH, aechh); in ov7670_s_exp()
1378 ret = ov7670_write(sd, REG_COM8, com8 & ~COM8_AEC); in ov7670_s_exp()
1385 static int ov7670_s_autoexp(struct v4l2_subdev *sd, in ov7670_s_autoexp() argument
1391 ret = ov7670_read(sd, REG_COM8, &com8); in ov7670_s_autoexp()
1397 ret = ov7670_write(sd, REG_COM8, com8); in ov7670_s_autoexp()
1405 struct v4l2_subdev *sd = to_sd(ctrl); in ov7670_g_volatile_ctrl() local
1406 struct ov7670_info *info = to_state(sd); in ov7670_g_volatile_ctrl()
1410 return ov7670_g_gain(sd, &info->gain->val); in ov7670_g_volatile_ctrl()
1417 struct v4l2_subdev *sd = to_sd(ctrl); in ov7670_s_ctrl() local
1418 struct ov7670_info *info = to_state(sd); in ov7670_s_ctrl()
1422 return ov7670_s_brightness(sd, ctrl->val); in ov7670_s_ctrl()
1424 return ov7670_s_contrast(sd, ctrl->val); in ov7670_s_ctrl()
1426 return ov7670_s_sat_hue(sd, in ov7670_s_ctrl()
1429 return ov7670_s_vflip(sd, ctrl->val); in ov7670_s_ctrl()
1431 return ov7670_s_hflip(sd, ctrl->val); in ov7670_s_ctrl()
1437 return ov7670_s_gain(sd, info->gain->val); in ov7670_s_ctrl()
1439 return ov7670_s_autogain(sd, ctrl->val); in ov7670_s_ctrl()
1445 return ov7670_s_exp(sd, info->exposure->val); in ov7670_s_ctrl()
1447 return ov7670_s_autoexp(sd, ctrl->val); in ov7670_s_ctrl()
1458 static int ov7670_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) in ov7670_g_register() argument
1463 ret = ov7670_read(sd, reg->reg & 0xff, &val); in ov7670_g_register()
1469 static int ov7670_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) in ov7670_s_register() argument
1471 ov7670_write(sd, reg->reg & 0xff, reg->val & 0xff); in ov7670_s_register()
1527 struct v4l2_subdev *sd; in ov7670_probe() local
1534 sd = &info->sd; in ov7670_probe()
1535 v4l2_i2c_subdev_init(sd, client, &ov7670_ops); in ov7670_probe()
1564 ret = ov7670_detect(sd); in ov7670_probe()
1581 info->devtype->set_framerate(sd, &tpf); in ov7670_probe()
1584 ov7670_write(sd, REG_COM10, COM10_PCLK_HB); in ov7670_probe()
1608 sd->ctrl_handler = &info->hdl; in ov7670_probe()
1631 struct v4l2_subdev *sd = i2c_get_clientdata(client); in ov7670_remove() local
1632 struct ov7670_info *info = to_state(sd); in ov7670_remove()
1634 v4l2_device_unregister_subdev(sd); in ov7670_remove()