Lines Matching refs:os03b10

129 struct os03b10 {  struct
162 #define to_os03b10(sd) container_of(sd, struct os03b10, subdev) argument
396 os03b10_find_best_fit(struct os03b10 *os03b10, struct v4l2_subdev_format *fmt) in os03b10_find_best_fit() argument
404 for (i = 0; i < os03b10->cfg_num; i++) { in os03b10_find_best_fit()
420 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_set_fmt() local
426 mutex_lock(&os03b10->mutex); in os03b10_set_fmt()
428 mode = os03b10_find_best_fit(os03b10, fmt); in os03b10_set_fmt()
437 mutex_unlock(&os03b10->mutex); in os03b10_set_fmt()
441 os03b10->cur_mode = mode; in os03b10_set_fmt()
443 __v4l2_ctrl_modify_range(os03b10->hblank, h_blank, in os03b10_set_fmt()
447 __v4l2_ctrl_modify_range(os03b10->vblank, vblank_def, in os03b10_set_fmt()
456 __v4l2_ctrl_s_ctrl_int64(os03b10->pixel_rate, in os03b10_set_fmt()
458 __v4l2_ctrl_s_ctrl(os03b10->link_freq, in os03b10_set_fmt()
462 mutex_unlock(&os03b10->mutex); in os03b10_set_fmt()
471 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_get_fmt() local
472 const struct os03b10_mode *mode = os03b10->cur_mode; in os03b10_get_fmt()
474 mutex_lock(&os03b10->mutex); in os03b10_get_fmt()
479 mutex_unlock(&os03b10->mutex); in os03b10_get_fmt()
492 mutex_unlock(&os03b10->mutex); in os03b10_get_fmt()
501 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_enum_mbus_code() local
505 code->code = os03b10->cur_mode->bus_fmt; in os03b10_enum_mbus_code()
514 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_enum_frame_sizes() local
516 if (fse->index >= os03b10->cfg_num) in os03b10_enum_frame_sizes()
533 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_g_frame_interval() local
534 const struct os03b10_mode *mode = os03b10->cur_mode; in os03b10_g_frame_interval()
544 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_g_mbus_config() local
545 const struct os03b10_mode *mode = os03b10->cur_mode; in os03b10_g_mbus_config()
559 static void os03b10_get_module_inf(struct os03b10 *os03b10, in os03b10_get_module_inf() argument
564 strscpy(inf->base.module, os03b10->module_name, sizeof(inf->base.module)); in os03b10_get_module_inf()
565 strscpy(inf->base.lens, os03b10->len_name, sizeof(inf->base.lens)); in os03b10_get_module_inf()
570 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_ioctl() local
577 os03b10_get_module_inf(os03b10, (struct rkmodule_inf *)arg); in os03b10_ioctl()
587 hdr_cfg->hdr_mode = os03b10->cur_mode->hdr_mode; in os03b10_ioctl()
592 ret = os03b10_write_reg(os03b10->client, OS03B10_REG_CTRL_MODE, in os03b10_ioctl()
595 ret = os03b10_write_reg(os03b10->client, OS03B10_REG_CTRL_MODE, in os03b10_ioctl()
675 static int __os03b10_start_stream(struct os03b10 *os03b10) in __os03b10_start_stream() argument
679 ret |= os03b10_write_array(os03b10->client, os03b10->cur_mode->reg_list); in __os03b10_start_stream()
681 dev_err(&os03b10->client->dev, in __os03b10_start_stream()
687 ret = __v4l2_ctrl_handler_setup(&os03b10->ctrl_handler); in __os03b10_start_stream()
690 if (os03b10->has_init_exp && os03b10->cur_mode->hdr_mode != NO_HDR) { in __os03b10_start_stream()
691 ret = os03b10_ioctl(&os03b10->subdev, PREISP_CMD_SET_HDRAE_EXP, in __os03b10_start_stream()
692 &os03b10->init_hdrae_exp); in __os03b10_start_stream()
694 dev_err(&os03b10->client->dev, in __os03b10_start_stream()
700 ret |= os03b10_write_reg(os03b10->client, OS03B10_REG_PAGE_SELECT, 0x01); in __os03b10_start_stream()
701 ret |= os03b10_write_reg(os03b10->client, OS03B10_REG_CTRL_MODE, in __os03b10_start_stream()
707 static int __os03b10_stop_stream(struct os03b10 *os03b10) in __os03b10_stop_stream() argument
709 os03b10->has_init_exp = false; in __os03b10_stop_stream()
710 return os03b10_write_reg(os03b10->client, OS03B10_REG_CTRL_MODE, in __os03b10_stop_stream()
716 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_s_stream() local
717 struct i2c_client *client = os03b10->client; in os03b10_s_stream()
720 mutex_lock(&os03b10->mutex); in os03b10_s_stream()
722 if (on == os03b10->streaming) in os03b10_s_stream()
732 ret = __os03b10_start_stream(os03b10); in os03b10_s_stream()
739 __os03b10_stop_stream(os03b10); in os03b10_s_stream()
743 os03b10->streaming = on; in os03b10_s_stream()
746 mutex_unlock(&os03b10->mutex); in os03b10_s_stream()
753 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_s_power() local
754 struct i2c_client *client = os03b10->client; in os03b10_s_power()
757 mutex_lock(&os03b10->mutex); in os03b10_s_power()
760 if (os03b10->power_on == !!on) in os03b10_s_power()
770 ret |= os03b10_write_reg(os03b10->client, in os03b10_s_power()
775 os03b10->power_on = true; in os03b10_s_power()
778 os03b10->power_on = false; in os03b10_s_power()
782 mutex_unlock(&os03b10->mutex); in os03b10_s_power()
787 static int __os03b10_power_on(struct os03b10 *os03b10) in __os03b10_power_on() argument
790 struct device *dev = &os03b10->client->dev; in __os03b10_power_on()
792 if (!IS_ERR_OR_NULL(os03b10->pins_default)) { in __os03b10_power_on()
793 ret = pinctrl_select_state(os03b10->pinctrl, in __os03b10_power_on()
794 os03b10->pins_default); in __os03b10_power_on()
798 ret = clk_set_rate(os03b10->xvclk, OS03B10_XVCLK_FREQ); in __os03b10_power_on()
801 if (clk_get_rate(os03b10->xvclk) != OS03B10_XVCLK_FREQ) in __os03b10_power_on()
803 ret = clk_prepare_enable(os03b10->xvclk); in __os03b10_power_on()
809 if (!IS_ERR(os03b10->pwdn_gpio)) in __os03b10_power_on()
810 gpiod_direction_output(os03b10->pwdn_gpio, 0); in __os03b10_power_on()
812 if (!IS_ERR(os03b10->reset_gpio)) in __os03b10_power_on()
813 gpiod_direction_output(os03b10->reset_gpio, 0); in __os03b10_power_on()
815 ret = regulator_bulk_enable(OS03B10_NUM_SUPPLIES, os03b10->supplies); in __os03b10_power_on()
823 if (!IS_ERR(os03b10->pwdn_gpio)) in __os03b10_power_on()
824 gpiod_direction_output(os03b10->pwdn_gpio, 1); in __os03b10_power_on()
828 if (!IS_ERR(os03b10->reset_gpio)) in __os03b10_power_on()
829 gpiod_direction_output(os03b10->reset_gpio, 1); in __os03b10_power_on()
836 clk_disable_unprepare(os03b10->xvclk); in __os03b10_power_on()
841 static void __os03b10_power_off(struct os03b10 *os03b10) in __os03b10_power_off() argument
844 struct device *dev = &os03b10->client->dev; in __os03b10_power_off()
846 if (!IS_ERR(os03b10->pwdn_gpio)) in __os03b10_power_off()
847 gpiod_direction_output(os03b10->pwdn_gpio, 0); in __os03b10_power_off()
849 clk_disable_unprepare(os03b10->xvclk); in __os03b10_power_off()
851 if (!IS_ERR(os03b10->reset_gpio)) in __os03b10_power_off()
852 gpiod_direction_output(os03b10->reset_gpio, 0); in __os03b10_power_off()
853 if (!IS_ERR_OR_NULL(os03b10->pins_sleep)) { in __os03b10_power_off()
854 ret = pinctrl_select_state(os03b10->pinctrl, in __os03b10_power_off()
855 os03b10->pins_sleep); in __os03b10_power_off()
859 regulator_bulk_disable(OS03B10_NUM_SUPPLIES, os03b10->supplies); in __os03b10_power_off()
866 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_runtime_resume() local
868 return __os03b10_power_on(os03b10); in os03b10_runtime_resume()
875 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_runtime_suspend() local
877 __os03b10_power_off(os03b10); in os03b10_runtime_suspend()
885 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_open() local
890 mutex_lock(&os03b10->mutex); in os03b10_open()
897 mutex_unlock(&os03b10->mutex); in os03b10_open()
908 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_enum_frame_interval() local
910 if (fie->index >= os03b10->cfg_num) in os03b10_enum_frame_interval()
993 struct os03b10 *os03b10 = container_of(ctrl->handler, in os03b10_set_ctrl() local
994 struct os03b10, ctrl_handler); in os03b10_set_ctrl()
995 struct i2c_client *client = os03b10->client; in os03b10_set_ctrl()
1004 max = os03b10->cur_mode->height + ctrl->val - 9; in os03b10_set_ctrl()
1005 __v4l2_ctrl_modify_range(os03b10->exposure, in os03b10_set_ctrl()
1006 os03b10->exposure->minimum, max, in os03b10_set_ctrl()
1007 os03b10->exposure->step, in os03b10_set_ctrl()
1008 os03b10->exposure->default_value); in os03b10_set_ctrl()
1017 ret = os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1019 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1022 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1025 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1032 ret = os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1034 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1037 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1040 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1043 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1050 ret = os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1052 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1055 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1058 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1066 os03b10->flip |= MIRROR_BIT_MASK; in os03b10_set_ctrl()
1068 os03b10->flip &= ~MIRROR_BIT_MASK; in os03b10_set_ctrl()
1070 ret = os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1072 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1073 OS03B10_FLIP_REG, os03b10->flip); in os03b10_set_ctrl()
1074 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1076 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1078 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1080 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1082 dev_dbg(&client->dev, "set hflip 0x%x\n", os03b10->flip); in os03b10_set_ctrl()
1086 os03b10->flip |= FLIP_BIT_MASK; in os03b10_set_ctrl()
1088 os03b10->flip &= ~FLIP_BIT_MASK; in os03b10_set_ctrl()
1090 ret = os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1092 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1093 OS03B10_FLIP_REG, os03b10->flip); in os03b10_set_ctrl()
1094 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1096 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1098 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1100 ret |= os03b10_write_reg(os03b10->client, in os03b10_set_ctrl()
1102 dev_dbg(&client->dev, "set vflip 0x%x\n", os03b10->flip); in os03b10_set_ctrl()
1118 static int os03b10_initialize_controls(struct os03b10 *os03b10) in os03b10_initialize_controls() argument
1128 handler = &os03b10->ctrl_handler; in os03b10_initialize_controls()
1129 mode = os03b10->cur_mode; in os03b10_initialize_controls()
1133 handler->lock = &os03b10->mutex; in os03b10_initialize_controls()
1135 os03b10->link_freq = v4l2_ctrl_new_int_menu(handler, NULL, in os03b10_initialize_controls()
1140 if (os03b10->cur_mode->bus_fmt == MEDIA_BUS_FMT_SBGGR10_1X10) { in os03b10_initialize_controls()
1145 os03b10->pixel_rate = v4l2_ctrl_new_std(handler, NULL, in os03b10_initialize_controls()
1150 __v4l2_ctrl_s_ctrl(os03b10->link_freq, dst_link_freq); in os03b10_initialize_controls()
1153 os03b10->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in os03b10_initialize_controls()
1155 if (os03b10->hblank) in os03b10_initialize_controls()
1156 os03b10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in os03b10_initialize_controls()
1159 os03b10->vblank = v4l2_ctrl_new_std(handler, &os03b10_ctrl_ops, in os03b10_initialize_controls()
1165 os03b10->exposure = v4l2_ctrl_new_std(handler, &os03b10_ctrl_ops, in os03b10_initialize_controls()
1170 os03b10->anal_gain = v4l2_ctrl_new_std(handler, &os03b10_ctrl_ops, in os03b10_initialize_controls()
1179 os03b10->flip = 0; in os03b10_initialize_controls()
1183 dev_err(&os03b10->client->dev, in os03b10_initialize_controls()
1188 os03b10->subdev.ctrl_handler = handler; in os03b10_initialize_controls()
1189 os03b10->has_init_exp = false; in os03b10_initialize_controls()
1199 static int os03b10_check_sensor_id(struct os03b10 *os03b10, in os03b10_check_sensor_id() argument
1202 struct device *dev = &os03b10->client->dev; in os03b10_check_sensor_id()
1219 static int os03b10_configure_regulators(struct os03b10 *os03b10) in os03b10_configure_regulators() argument
1224 os03b10->supplies[i].supply = OS03B10_supply_names[i]; in os03b10_configure_regulators()
1226 return devm_regulator_bulk_get(&os03b10->client->dev, in os03b10_configure_regulators()
1228 os03b10->supplies); in os03b10_configure_regulators()
1236 struct os03b10 *os03b10; in os03b10_probe() local
1247 os03b10 = devm_kzalloc(dev, sizeof(*os03b10), GFP_KERNEL); in os03b10_probe()
1248 if (!os03b10) in os03b10_probe()
1252 &os03b10->module_index); in os03b10_probe()
1254 &os03b10->module_facing); in os03b10_probe()
1256 &os03b10->module_name); in os03b10_probe()
1258 &os03b10->len_name); in os03b10_probe()
1269 os03b10->cfg_num = ARRAY_SIZE(supported_modes); in os03b10_probe()
1270 for (i = 0; i < os03b10->cfg_num; i++) { in os03b10_probe()
1272 os03b10->cur_mode = &supported_modes[i]; in os03b10_probe()
1276 os03b10->client = client; in os03b10_probe()
1278 os03b10->xvclk = devm_clk_get(dev, "xvclk"); in os03b10_probe()
1279 if (IS_ERR(os03b10->xvclk)) { in os03b10_probe()
1284 os03b10->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_ASIS); in os03b10_probe()
1285 if (IS_ERR(os03b10->reset_gpio)) in os03b10_probe()
1288 os03b10->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_ASIS); in os03b10_probe()
1289 if (IS_ERR(os03b10->pwdn_gpio)) in os03b10_probe()
1292 os03b10->pinctrl = devm_pinctrl_get(dev); in os03b10_probe()
1293 if (!IS_ERR(os03b10->pinctrl)) { in os03b10_probe()
1294 os03b10->pins_default = in os03b10_probe()
1295 pinctrl_lookup_state(os03b10->pinctrl, in os03b10_probe()
1297 if (IS_ERR(os03b10->pins_default)) in os03b10_probe()
1300 os03b10->pins_sleep = in os03b10_probe()
1301 pinctrl_lookup_state(os03b10->pinctrl, in os03b10_probe()
1303 if (IS_ERR(os03b10->pins_sleep)) in os03b10_probe()
1309 ret = os03b10_configure_regulators(os03b10); in os03b10_probe()
1315 mutex_init(&os03b10->mutex); in os03b10_probe()
1317 sd = &os03b10->subdev; in os03b10_probe()
1319 ret = os03b10_initialize_controls(os03b10); in os03b10_probe()
1323 ret = __os03b10_power_on(os03b10); in os03b10_probe()
1327 ret = os03b10_check_sensor_id(os03b10, client); in os03b10_probe()
1336 os03b10->pad.flags = MEDIA_PAD_FL_SOURCE; in os03b10_probe()
1338 ret = media_entity_pads_init(&sd->entity, 1, &os03b10->pad); in os03b10_probe()
1344 if (strcmp(os03b10->module_facing, "back") == 0) in os03b10_probe()
1350 os03b10->module_index, facing, in os03b10_probe()
1369 __os03b10_power_off(os03b10); in os03b10_probe()
1371 v4l2_ctrl_handler_free(&os03b10->ctrl_handler); in os03b10_probe()
1373 mutex_destroy(&os03b10->mutex); in os03b10_probe()
1381 struct os03b10 *os03b10 = to_os03b10(sd); in os03b10_remove() local
1387 v4l2_ctrl_handler_free(&os03b10->ctrl_handler); in os03b10_remove()
1388 mutex_destroy(&os03b10->mutex); in os03b10_remove()
1392 __os03b10_power_off(os03b10); in os03b10_remove()