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…
103 * struct gc2145_mode - GC2145 mode description
540 * struct gc2145_format - GC2145 pixel format description
544 * @output_fmt: GC2145 output format
545 * @switch_bit: GC2145 first/second switch
546 * @row_col_switch: GC2145 switch row and/or column
631 struct gc2145 { struct
649 static inline struct gc2145 *to_gc2145(struct v4l2_subdev *_sd) in to_gc2145() argument
651 return container_of(_sd, struct gc2145, sd); in to_gc2145()
656 return &container_of(ctrl->handler, struct gc2145, in gc2145_ctrl_to_sd()
661 gc2145_get_format_code(struct gc2145 *gc2145, u32 code) in gc2145_get_format_code() argument
676 static void gc2145_update_pad_format(struct gc2145 *gc2145, in gc2145_update_pad_format() argument
694 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_init_state() local
700 gc2145_update_pad_format(gc2145, &supported_modes[0], format, in gc2145_init_state()
756 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_enum_frame_size() local
763 gc2145_format = gc2145_get_format_code(gc2145, fse->code); in gc2145_enum_frame_size()
780 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_set_pad_format() local
784 struct gc2145_ctrls *ctrls = &gc2145->ctrls; in gc2145_set_pad_format()
787 gc2145_fmt = gc2145_get_format_code(gc2145, fmt->format.code); in gc2145_set_pad_format()
798 gc2145_update_pad_format(gc2145, mode, &fmt->format, gc2145_fmt->code, in gc2145_set_pad_format()
802 gc2145->mode = mode; in gc2145_set_pad_format()
840 static int gc2145_config_mipi_mode(struct gc2145 *gc2145, in gc2145_config_mipi_mode() argument
847 cci_multi_reg_write(gc2145->regmap, gc2145_common_mipi_regs, in gc2145_config_mipi_mode()
857 lwc = gc2145->mode->width * 2; in gc2145_config_mipi_mode()
859 lwc = gc2145->mode->width; in gc2145_config_mipi_mode()
861 cci_write(gc2145->regmap, GC2145_REG_LWC, lwc, &ret); in gc2145_config_mipi_mode()
870 if (gc2145->mode->width == 1280 || gc2145->mode->width == 1600) in gc2145_config_mipi_mode()
878 cci_write(gc2145->regmap, GC2145_REG_FIFO_FULL_LVL, in gc2145_config_mipi_mode()
885 cci_write(gc2145->regmap, GC2145_REG_FIFO_GATE_MODE, in gc2145_config_mipi_mode()
890 cci_write(gc2145->regmap, GC2145_REG_MIPI_DT, in gc2145_config_mipi_mode()
894 cci_write(gc2145->regmap, GC2145_REG_BUF_CSI2_MODE, in gc2145_config_mipi_mode()
905 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_enable_streams() local
906 struct i2c_client *client = v4l2_get_subdevdata(&gc2145->sd); in gc2145_enable_streams()
916 cci_multi_reg_write(gc2145->regmap, gc2145->mode->reg_seq, in gc2145_enable_streams()
917 gc2145->mode->reg_seq_size, &ret); in gc2145_enable_streams()
918 cci_multi_reg_write(gc2145->regmap, gc2145_common_regs, in gc2145_enable_streams()
926 gc2145_format = gc2145_get_format_code(gc2145, fmt->code); in gc2145_enable_streams()
929 cci_write(gc2145->regmap, GC2145_REG_PAGE_SELECT, 0x00, &ret); in gc2145_enable_streams()
931 cci_write(gc2145->regmap, GC2145_REG_OUTPUT_FMT, in gc2145_enable_streams()
933 cci_update_bits(gc2145->regmap, GC2145_REG_BYPASS_MODE, in gc2145_enable_streams()
937 cci_update_bits(gc2145->regmap, GC2145_REG_SYNC_MODE, in gc2145_enable_streams()
947 ret = __v4l2_ctrl_handler_setup(&gc2145->ctrls.handler); in gc2145_enable_streams()
954 ret = gc2145_config_mipi_mode(gc2145, gc2145_format); in gc2145_enable_streams()
961 cci_write(gc2145->regmap, GC2145_REG_PAGE_SELECT, 0x00, &ret); in gc2145_enable_streams()
975 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_disable_streams() local
976 struct i2c_client *client = v4l2_get_subdevdata(&gc2145->sd); in gc2145_disable_streams()
980 cci_write(gc2145->regmap, GC2145_REG_PAGE_SELECT, 0x03, &ret); in gc2145_disable_streams()
981 cci_update_bits(gc2145->regmap, GC2145_REG_BUF_CSI2_MODE, in gc2145_disable_streams()
984 cci_write(gc2145->regmap, GC2145_REG_PAGE_SELECT, 0x00, &ret); in gc2145_disable_streams()
998 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_power_on() local
1001 ret = regulator_bulk_enable(GC2145_NUM_SUPPLIES, gc2145->supplies); in gc2145_power_on()
1007 ret = clk_prepare_enable(gc2145->xclk); in gc2145_power_on()
1013 gpiod_set_value_cansleep(gc2145->powerdown_gpio, 0); in gc2145_power_on()
1014 gpiod_set_value_cansleep(gc2145->reset_gpio, 0); in gc2145_power_on()
1026 regulator_bulk_disable(GC2145_NUM_SUPPLIES, gc2145->supplies); in gc2145_power_on()
1034 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_power_off() local
1036 gpiod_set_value_cansleep(gc2145->powerdown_gpio, 1); in gc2145_power_off()
1037 gpiod_set_value_cansleep(gc2145->reset_gpio, 1); in gc2145_power_off()
1038 clk_disable_unprepare(gc2145->xclk); in gc2145_power_off()
1039 regulator_bulk_disable(GC2145_NUM_SUPPLIES, gc2145->supplies); in gc2145_power_off()
1044 static int gc2145_get_regulators(struct gc2145 *gc2145) in gc2145_get_regulators() argument
1046 struct i2c_client *client = v4l2_get_subdevdata(&gc2145->sd); in gc2145_get_regulators()
1050 gc2145->supplies[i].supply = gc2145_supply_name[i]; in gc2145_get_regulators()
1053 gc2145->supplies); in gc2145_get_regulators()
1057 static int gc2145_identify_module(struct gc2145 *gc2145) in gc2145_identify_module() argument
1059 struct i2c_client *client = v4l2_get_subdevdata(&gc2145->sd); in gc2145_identify_module()
1063 ret = cci_read(gc2145->regmap, GC2145_REG_CHIP_ID, &chip_id, NULL); in gc2145_identify_module()
1137 static int gc2145_set_ctrl_test_pattern(struct gc2145 *gc2145, int value) in gc2145_set_ctrl_test_pattern() argument
1143 cci_write(gc2145->regmap, GC2145_REG_DEBUG_MODE2, 0, &ret); in gc2145_set_ctrl_test_pattern()
1144 return cci_write(gc2145->regmap, GC2145_REG_DEBUG_MODE3, 0, in gc2145_set_ctrl_test_pattern()
1149 cci_write(gc2145->regmap, GC2145_REG_DEBUG_MODE2, in gc2145_set_ctrl_test_pattern()
1153 return cci_write(gc2145->regmap, GC2145_REG_DEBUG_MODE3, 0, in gc2145_set_ctrl_test_pattern()
1157 return cci_write(gc2145->regmap, GC2145_REG_DEBUG_MODE3, in gc2145_set_ctrl_test_pattern()
1165 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_s_ctrl() local
1173 ret = cci_write(gc2145->regmap, GC2145_REG_HBLANK, ctrl->val, in gc2145_s_ctrl()
1177 ret = cci_write(gc2145->regmap, GC2145_REG_VBLANK, ctrl->val, in gc2145_s_ctrl()
1181 ret = gc2145_set_ctrl_test_pattern(gc2145, ctrl->val); in gc2145_s_ctrl()
1184 ret = cci_update_bits(gc2145->regmap, GC2145_REG_ANALOG_MODE1, in gc2145_s_ctrl()
1188 ret = cci_update_bits(gc2145->regmap, GC2145_REG_ANALOG_MODE1, in gc2145_s_ctrl()
1207 static int gc2145_init_controls(struct gc2145 *gc2145) in gc2145_init_controls() argument
1209 struct i2c_client *client = v4l2_get_subdevdata(&gc2145->sd); in gc2145_init_controls()
1211 struct gc2145_ctrls *ctrls = &gc2145->ctrls; in gc2145_init_controls()
1261 gc2145->sd.ctrl_handler = hdl; in gc2145_init_controls()
1322 struct gc2145 *gc2145; in gc2145_probe() local
1325 gc2145 = devm_kzalloc(&client->dev, sizeof(*gc2145), GFP_KERNEL); in gc2145_probe()
1326 if (!gc2145) in gc2145_probe()
1329 v4l2_i2c_subdev_init(&gc2145->sd, client, &gc2145_subdev_ops); in gc2145_probe()
1330 gc2145->sd.internal_ops = &gc2145_subdev_internal_ops; in gc2145_probe()
1337 gc2145->xclk = devm_clk_get(dev, NULL); in gc2145_probe()
1338 if (IS_ERR(gc2145->xclk)) in gc2145_probe()
1339 return dev_err_probe(dev, PTR_ERR(gc2145->xclk), in gc2145_probe()
1342 xclk_freq = clk_get_rate(gc2145->xclk); in gc2145_probe()
1349 ret = gc2145_get_regulators(gc2145); in gc2145_probe()
1355 gc2145->reset_gpio = devm_gpiod_get_optional(dev, "reset", in gc2145_probe()
1357 if (IS_ERR(gc2145->reset_gpio)) in gc2145_probe()
1358 return dev_err_probe(dev, PTR_ERR(gc2145->reset_gpio), in gc2145_probe()
1362 gc2145->powerdown_gpio = devm_gpiod_get_optional(dev, "powerdown", in gc2145_probe()
1364 if (IS_ERR(gc2145->powerdown_gpio)) in gc2145_probe()
1365 return dev_err_probe(dev, PTR_ERR(gc2145->powerdown_gpio), in gc2145_probe()
1369 gc2145->regmap = devm_cci_regmap_init_i2c(client, 8); in gc2145_probe()
1370 if (IS_ERR(gc2145->regmap)) in gc2145_probe()
1371 return dev_err_probe(dev, PTR_ERR(gc2145->regmap), in gc2145_probe()
1382 ret = gc2145_identify_module(gc2145); in gc2145_probe()
1387 gc2145->mode = &supported_modes[0]; in gc2145_probe()
1389 ret = gc2145_init_controls(gc2145); in gc2145_probe()
1394 gc2145->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in gc2145_probe()
1395 gc2145->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in gc2145_probe()
1398 gc2145->pad.flags = MEDIA_PAD_FL_SOURCE; in gc2145_probe()
1400 ret = media_entity_pads_init(&gc2145->sd.entity, 1, &gc2145->pad); in gc2145_probe()
1406 gc2145->sd.state_lock = gc2145->ctrls.handler.lock; in gc2145_probe()
1407 ret = v4l2_subdev_init_finalize(&gc2145->sd); in gc2145_probe()
1422 ret = v4l2_async_register_subdev_sensor(&gc2145->sd); in gc2145_probe()
1431 v4l2_subdev_cleanup(&gc2145->sd); in gc2145_probe()
1436 media_entity_cleanup(&gc2145->sd.entity); in gc2145_probe()
1439 v4l2_ctrl_handler_free(&gc2145->ctrls.handler); in gc2145_probe()
1450 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_remove() local
1455 v4l2_ctrl_handler_free(&gc2145->ctrls.handler); in gc2145_remove()
1464 { .compatible = "galaxycore,gc2145" },
1475 .name = "gc2145",
1486 MODULE_DESCRIPTION("GalaxyCore GC2145 sensor driver");