Lines Matching full:gc2145
3 * A V4L2 driver for Galaxycore GC2145 camera.
8 …* Datasheet v1.0 available at http://files.pine64.org/doc/datasheet/PinebookPro/GC2145%20CSP%20Dat…
104 * struct gc2145_mode - GC2145 mode description
541 * struct gc2145_format - GC2145 pixel format description
545 * @output_fmt: GC2145 output format
546 * @switch_bit: GC2145 first/second switch
547 * @row_col_switch: GC2145 switch row and/or column
632 struct gc2145 { struct
650 static inline struct gc2145 *to_gc2145(struct v4l2_subdev *_sd) in to_gc2145() argument
652 return container_of(_sd, struct gc2145, sd); in to_gc2145()
657 return &container_of(ctrl->handler, struct gc2145, in gc2145_ctrl_to_sd()
662 gc2145_get_format_code(struct gc2145 *gc2145, u32 code) in gc2145_get_format_code() argument
677 static void gc2145_update_pad_format(struct gc2145 *gc2145, in gc2145_update_pad_format() argument
695 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_init_state() local
701 gc2145_update_pad_format(gc2145, &supported_modes[0], format, in gc2145_init_state()
757 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_enum_frame_size() local
764 gc2145_format = gc2145_get_format_code(gc2145, fse->code); in gc2145_enum_frame_size()
781 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_set_pad_format() local
785 struct gc2145_ctrls *ctrls = &gc2145->ctrls; in gc2145_set_pad_format()
788 gc2145_fmt = gc2145_get_format_code(gc2145, fmt->format.code); in gc2145_set_pad_format()
799 gc2145_update_pad_format(gc2145, mode, &fmt->format, gc2145_fmt->code, in gc2145_set_pad_format()
803 gc2145->mode = mode; in gc2145_set_pad_format()
841 static int gc2145_config_mipi_mode(struct gc2145 *gc2145, in gc2145_config_mipi_mode() argument
848 cci_multi_reg_write(gc2145->regmap, gc2145_common_mipi_regs, in gc2145_config_mipi_mode()
858 lwc = gc2145->mode->width * 2; in gc2145_config_mipi_mode()
860 lwc = gc2145->mode->width; in gc2145_config_mipi_mode()
862 cci_write(gc2145->regmap, GC2145_REG_LWC, lwc, &ret); in gc2145_config_mipi_mode()
871 if (gc2145->mode->width == 1280 || gc2145->mode->width == 1600) in gc2145_config_mipi_mode()
879 cci_write(gc2145->regmap, GC2145_REG_FIFO_FULL_LVL, in gc2145_config_mipi_mode()
886 cci_write(gc2145->regmap, GC2145_REG_FIFO_GATE_MODE, in gc2145_config_mipi_mode()
891 cci_write(gc2145->regmap, GC2145_REG_MIPI_DT, in gc2145_config_mipi_mode()
895 cci_write(gc2145->regmap, GC2145_REG_BUF_CSI2_MODE, in gc2145_config_mipi_mode()
902 static int gc2145_start_streaming(struct gc2145 *gc2145, in gc2145_start_streaming() argument
905 struct i2c_client *client = v4l2_get_subdevdata(&gc2145->sd); in gc2145_start_streaming()
915 cci_multi_reg_write(gc2145->regmap, gc2145->mode->reg_seq, in gc2145_start_streaming()
916 gc2145->mode->reg_seq_size, &ret); in gc2145_start_streaming()
917 cci_multi_reg_write(gc2145->regmap, gc2145_common_regs, in gc2145_start_streaming()
925 gc2145_format = gc2145_get_format_code(gc2145, fmt->code); in gc2145_start_streaming()
928 cci_write(gc2145->regmap, GC2145_REG_PAGE_SELECT, 0x00, &ret); in gc2145_start_streaming()
930 cci_write(gc2145->regmap, GC2145_REG_OUTPUT_FMT, in gc2145_start_streaming()
932 cci_update_bits(gc2145->regmap, GC2145_REG_BYPASS_MODE, in gc2145_start_streaming()
936 cci_update_bits(gc2145->regmap, GC2145_REG_SYNC_MODE, in gc2145_start_streaming()
946 ret = __v4l2_ctrl_handler_setup(&gc2145->ctrls.handler); in gc2145_start_streaming()
953 ret = gc2145_config_mipi_mode(gc2145, gc2145_format); in gc2145_start_streaming()
960 cci_write(gc2145->regmap, GC2145_REG_PAGE_SELECT, 0x00, &ret); in gc2145_start_streaming()
970 static void gc2145_stop_streaming(struct gc2145 *gc2145) in gc2145_stop_streaming() argument
972 struct i2c_client *client = v4l2_get_subdevdata(&gc2145->sd); in gc2145_stop_streaming()
976 cci_write(gc2145->regmap, GC2145_REG_PAGE_SELECT, 0x03, &ret); in gc2145_stop_streaming()
977 cci_update_bits(gc2145->regmap, GC2145_REG_BUF_CSI2_MODE, in gc2145_stop_streaming()
980 cci_write(gc2145->regmap, GC2145_REG_PAGE_SELECT, 0x00, &ret); in gc2145_stop_streaming()
990 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_set_stream() local
997 ret = gc2145_start_streaming(gc2145, state); in gc2145_set_stream()
999 gc2145_stop_streaming(gc2145); in gc2145_set_stream()
1010 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_power_on() local
1013 ret = regulator_bulk_enable(GC2145_NUM_SUPPLIES, gc2145->supplies); in gc2145_power_on()
1019 ret = clk_prepare_enable(gc2145->xclk); in gc2145_power_on()
1025 gpiod_set_value_cansleep(gc2145->powerdown_gpio, 0); in gc2145_power_on()
1026 gpiod_set_value_cansleep(gc2145->reset_gpio, 0); in gc2145_power_on()
1038 regulator_bulk_disable(GC2145_NUM_SUPPLIES, gc2145->supplies); in gc2145_power_on()
1046 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_power_off() local
1048 gpiod_set_value_cansleep(gc2145->powerdown_gpio, 1); in gc2145_power_off()
1049 gpiod_set_value_cansleep(gc2145->reset_gpio, 1); in gc2145_power_off()
1050 clk_disable_unprepare(gc2145->xclk); in gc2145_power_off()
1051 regulator_bulk_disable(GC2145_NUM_SUPPLIES, gc2145->supplies); in gc2145_power_off()
1056 static int gc2145_get_regulators(struct gc2145 *gc2145) in gc2145_get_regulators() argument
1058 struct i2c_client *client = v4l2_get_subdevdata(&gc2145->sd); in gc2145_get_regulators()
1062 gc2145->supplies[i].supply = gc2145_supply_name[i]; in gc2145_get_regulators()
1065 gc2145->supplies); in gc2145_get_regulators()
1069 static int gc2145_identify_module(struct gc2145 *gc2145) in gc2145_identify_module() argument
1071 struct i2c_client *client = v4l2_get_subdevdata(&gc2145->sd); in gc2145_identify_module()
1075 ret = cci_read(gc2145->regmap, GC2145_REG_CHIP_ID, &chip_id, NULL); in gc2145_identify_module()
1153 static int gc2145_set_ctrl_test_pattern(struct gc2145 *gc2145, int value) in gc2145_set_ctrl_test_pattern() argument
1159 cci_write(gc2145->regmap, GC2145_REG_DEBUG_MODE2, 0, &ret); in gc2145_set_ctrl_test_pattern()
1160 return cci_write(gc2145->regmap, GC2145_REG_DEBUG_MODE3, 0, in gc2145_set_ctrl_test_pattern()
1165 cci_write(gc2145->regmap, GC2145_REG_DEBUG_MODE2, in gc2145_set_ctrl_test_pattern()
1169 return cci_write(gc2145->regmap, GC2145_REG_DEBUG_MODE3, 0, in gc2145_set_ctrl_test_pattern()
1173 return cci_write(gc2145->regmap, GC2145_REG_DEBUG_MODE3, in gc2145_set_ctrl_test_pattern()
1181 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_s_ctrl() local
1189 ret = cci_write(gc2145->regmap, GC2145_REG_HBLANK, ctrl->val, in gc2145_s_ctrl()
1193 ret = cci_write(gc2145->regmap, GC2145_REG_VBLANK, ctrl->val, in gc2145_s_ctrl()
1197 ret = gc2145_set_ctrl_test_pattern(gc2145, ctrl->val); in gc2145_s_ctrl()
1200 ret = cci_update_bits(gc2145->regmap, GC2145_REG_ANALOG_MODE1, in gc2145_s_ctrl()
1204 ret = cci_update_bits(gc2145->regmap, GC2145_REG_ANALOG_MODE1, in gc2145_s_ctrl()
1223 static int gc2145_init_controls(struct gc2145 *gc2145) in gc2145_init_controls() argument
1225 struct i2c_client *client = v4l2_get_subdevdata(&gc2145->sd); in gc2145_init_controls()
1227 struct gc2145_ctrls *ctrls = &gc2145->ctrls; in gc2145_init_controls()
1277 gc2145->sd.ctrl_handler = hdl; in gc2145_init_controls()
1338 struct gc2145 *gc2145; in gc2145_probe() local
1341 gc2145 = devm_kzalloc(&client->dev, sizeof(*gc2145), GFP_KERNEL); in gc2145_probe()
1342 if (!gc2145) in gc2145_probe()
1345 v4l2_i2c_subdev_init(&gc2145->sd, client, &gc2145_subdev_ops); in gc2145_probe()
1346 gc2145->sd.internal_ops = &gc2145_subdev_internal_ops; in gc2145_probe()
1353 gc2145->xclk = devm_clk_get(dev, NULL); in gc2145_probe()
1354 if (IS_ERR(gc2145->xclk)) in gc2145_probe()
1355 return dev_err_probe(dev, PTR_ERR(gc2145->xclk), in gc2145_probe()
1358 xclk_freq = clk_get_rate(gc2145->xclk); in gc2145_probe()
1365 ret = gc2145_get_regulators(gc2145); in gc2145_probe()
1371 gc2145->reset_gpio = devm_gpiod_get_optional(dev, "reset", in gc2145_probe()
1373 if (IS_ERR(gc2145->reset_gpio)) in gc2145_probe()
1374 return dev_err_probe(dev, PTR_ERR(gc2145->reset_gpio), in gc2145_probe()
1378 gc2145->powerdown_gpio = devm_gpiod_get_optional(dev, "powerdown", in gc2145_probe()
1380 if (IS_ERR(gc2145->powerdown_gpio)) in gc2145_probe()
1381 return dev_err_probe(dev, PTR_ERR(gc2145->powerdown_gpio), in gc2145_probe()
1385 gc2145->regmap = devm_cci_regmap_init_i2c(client, 8); in gc2145_probe()
1386 if (IS_ERR(gc2145->regmap)) in gc2145_probe()
1387 return dev_err_probe(dev, PTR_ERR(gc2145->regmap), in gc2145_probe()
1398 ret = gc2145_identify_module(gc2145); in gc2145_probe()
1403 gc2145->mode = &supported_modes[0]; in gc2145_probe()
1405 ret = gc2145_init_controls(gc2145); in gc2145_probe()
1410 gc2145->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | in gc2145_probe()
1412 gc2145->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in gc2145_probe()
1415 gc2145->pad.flags = MEDIA_PAD_FL_SOURCE; in gc2145_probe()
1417 ret = media_entity_pads_init(&gc2145->sd.entity, 1, &gc2145->pad); in gc2145_probe()
1423 gc2145->sd.state_lock = gc2145->ctrls.handler.lock; in gc2145_probe()
1424 ret = v4l2_subdev_init_finalize(&gc2145->sd); in gc2145_probe()
1439 ret = v4l2_async_register_subdev_sensor(&gc2145->sd); in gc2145_probe()
1448 v4l2_subdev_cleanup(&gc2145->sd); in gc2145_probe()
1453 media_entity_cleanup(&gc2145->sd.entity); in gc2145_probe()
1456 v4l2_ctrl_handler_free(&gc2145->ctrls.handler); in gc2145_probe()
1467 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_remove() local
1472 v4l2_ctrl_handler_free(&gc2145->ctrls.handler); in gc2145_remove()
1481 { .compatible = "galaxycore,gc2145" },
1492 .name = "gc2145",
1503 MODULE_DESCRIPTION("GalaxyCore GC2145 sensor driver");