Symbol: ov5645
drivers/media/i2c/ov5645.c
1013
struct ov5645 *ov5645;
drivers/media/i2c/ov5645.c
1019
ov5645 = devm_kzalloc(dev, sizeof(struct ov5645), GFP_KERNEL);
drivers/media/i2c/ov5645.c
1020
if (!ov5645)
drivers/media/i2c/ov5645.c
1023
ov5645->i2c_client = client;
drivers/media/i2c/ov5645.c
1024
ov5645->dev = dev;
drivers/media/i2c/ov5645.c
1032
&ov5645->ep);
drivers/media/i2c/ov5645.c
1040
if (ov5645->ep.bus_type != V4L2_MBUS_CSI2_DPHY)
drivers/media/i2c/ov5645.c
1045
ov5645->xclk = devm_v4l2_sensor_clk_get_legacy(dev, NULL, false, 0);
drivers/media/i2c/ov5645.c
1046
if (IS_ERR(ov5645->xclk))
drivers/media/i2c/ov5645.c
1047
return dev_err_probe(dev, PTR_ERR(ov5645->xclk),
drivers/media/i2c/ov5645.c
1051
xclk_freq = clk_get_rate(ov5645->xclk);
drivers/media/i2c/ov5645.c
1058
ov5645->supplies[i].supply = ov5645_supply_name[i];
drivers/media/i2c/ov5645.c
1061
ov5645->supplies);
drivers/media/i2c/ov5645.c
1065
ov5645->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
drivers/media/i2c/ov5645.c
1066
if (IS_ERR(ov5645->enable_gpio))
drivers/media/i2c/ov5645.c
1067
return dev_err_probe(dev, PTR_ERR(ov5645->enable_gpio),
drivers/media/i2c/ov5645.c
1070
ov5645->rst_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
drivers/media/i2c/ov5645.c
1071
if (IS_ERR(ov5645->rst_gpio))
drivers/media/i2c/ov5645.c
1072
return dev_err_probe(dev, PTR_ERR(ov5645->rst_gpio),
drivers/media/i2c/ov5645.c
1075
v4l2_ctrl_handler_init(&ov5645->ctrls, 9);
drivers/media/i2c/ov5645.c
1076
v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
drivers/media/i2c/ov5645.c
1078
v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
drivers/media/i2c/ov5645.c
1080
v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
drivers/media/i2c/ov5645.c
1082
v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
drivers/media/i2c/ov5645.c
1084
v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
drivers/media/i2c/ov5645.c
1086
v4l2_ctrl_new_std_menu(&ov5645->ctrls, &ov5645_ctrl_ops,
drivers/media/i2c/ov5645.c
1089
v4l2_ctrl_new_std_menu_items(&ov5645->ctrls, &ov5645_ctrl_ops,
drivers/media/i2c/ov5645.c
1093
ov5645->pixel_clock = v4l2_ctrl_new_std(&ov5645->ctrls,
drivers/media/i2c/ov5645.c
1097
ov5645->link_freq = v4l2_ctrl_new_int_menu(&ov5645->ctrls,
drivers/media/i2c/ov5645.c
1102
if (ov5645->link_freq)
drivers/media/i2c/ov5645.c
1103
ov5645->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
drivers/media/i2c/ov5645.c
1105
ov5645->sd.ctrl_handler = &ov5645->ctrls;
drivers/media/i2c/ov5645.c
1107
if (ov5645->ctrls.error) {
drivers/media/i2c/ov5645.c
1108
ret = ov5645->ctrls.error;
drivers/media/i2c/ov5645.c
111
static inline struct ov5645 *to_ov5645(struct v4l2_subdev *sd)
drivers/media/i2c/ov5645.c
1113
v4l2_i2c_subdev_init(&ov5645->sd, client, &ov5645_subdev_ops);
drivers/media/i2c/ov5645.c
1114
ov5645->sd.internal_ops = &ov5645_internal_ops;
drivers/media/i2c/ov5645.c
1115
ov5645->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
drivers/media/i2c/ov5645.c
1116
ov5645->pad.flags = MEDIA_PAD_FL_SOURCE;
drivers/media/i2c/ov5645.c
1117
ov5645->sd.dev = dev;
drivers/media/i2c/ov5645.c
1118
ov5645->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
drivers/media/i2c/ov5645.c
1120
ret = media_entity_pads_init(&ov5645->sd.entity, 1, &ov5645->pad);
drivers/media/i2c/ov5645.c
113
return container_of(sd, struct ov5645, sd);
drivers/media/i2c/ov5645.c
1130
ret = ov5645_read_reg(ov5645, OV5645_CHIP_ID_HIGH, &chip_id_high);
drivers/media/i2c/ov5645.c
1136
ret = ov5645_read_reg(ov5645, OV5645_CHIP_ID_LOW, &chip_id_low);
drivers/media/i2c/ov5645.c
1145
ret = ov5645_read_reg(ov5645, OV5645_AEC_PK_MANUAL,
drivers/media/i2c/ov5645.c
1146
&ov5645->aec_pk_manual);
drivers/media/i2c/ov5645.c
1153
ret = ov5645_read_reg(ov5645, OV5645_TIMING_TC_REG20,
drivers/media/i2c/ov5645.c
1154
&ov5645->timing_tc_reg20);
drivers/media/i2c/ov5645.c
1161
ret = ov5645_read_reg(ov5645, OV5645_TIMING_TC_REG21,
drivers/media/i2c/ov5645.c
1162
&ov5645->timing_tc_reg21);
drivers/media/i2c/ov5645.c
1169
ov5645->sd.state_lock = ov5645->ctrls.lock;
drivers/media/i2c/ov5645.c
1170
ret = v4l2_subdev_init_finalize(&ov5645->sd);
drivers/media/i2c/ov5645.c
1180
ret = v4l2_async_register_subdev_sensor(&ov5645->sd);
drivers/media/i2c/ov5645.c
1195
v4l2_subdev_cleanup(&ov5645->sd);
drivers/media/i2c/ov5645.c
1199
media_entity_cleanup(&ov5645->sd.entity);
drivers/media/i2c/ov5645.c
1201
v4l2_ctrl_handler_free(&ov5645->ctrls);
drivers/media/i2c/ov5645.c
1209
struct ov5645 *ov5645 = to_ov5645(sd);
drivers/media/i2c/ov5645.c
1211
v4l2_async_unregister_subdev(&ov5645->sd);
drivers/media/i2c/ov5645.c
1213
media_entity_cleanup(&ov5645->sd.entity);
drivers/media/i2c/ov5645.c
1214
v4l2_ctrl_handler_free(&ov5645->ctrls);
drivers/media/i2c/ov5645.c
1215
pm_runtime_disable(ov5645->dev);
drivers/media/i2c/ov5645.c
1216
if (!pm_runtime_status_suspended(ov5645->dev))
drivers/media/i2c/ov5645.c
1217
ov5645_set_power_off(ov5645->dev);
drivers/media/i2c/ov5645.c
1218
pm_runtime_set_suspended(ov5645->dev);
drivers/media/i2c/ov5645.c
537
static int ov5645_write_reg(struct ov5645 *ov5645, u16 reg, u8 val)
drivers/media/i2c/ov5645.c
546
ret = i2c_master_send(ov5645->i2c_client, regbuf, 3);
drivers/media/i2c/ov5645.c
548
dev_err(ov5645->dev, "%s: write reg error %d: reg=%x, val=%x\n",
drivers/media/i2c/ov5645.c
556
static int ov5645_read_reg(struct ov5645 *ov5645, u16 reg, u8 *val)
drivers/media/i2c/ov5645.c
564
ret = i2c_master_send(ov5645->i2c_client, regbuf, 2);
drivers/media/i2c/ov5645.c
566
dev_err(ov5645->dev, "%s: write reg error %d: reg=%x\n",
drivers/media/i2c/ov5645.c
571
ret = i2c_master_recv(ov5645->i2c_client, val, 1);
drivers/media/i2c/ov5645.c
573
dev_err(ov5645->dev, "%s: read reg error %d: reg=%x\n",
drivers/media/i2c/ov5645.c
581
static int ov5645_set_aec_mode(struct ov5645 *ov5645, u32 mode)
drivers/media/i2c/ov5645.c
583
u8 val = ov5645->aec_pk_manual;
drivers/media/i2c/ov5645.c
591
ret = ov5645_write_reg(ov5645, OV5645_AEC_PK_MANUAL, val);
drivers/media/i2c/ov5645.c
593
ov5645->aec_pk_manual = val;
drivers/media/i2c/ov5645.c
598
static int ov5645_set_agc_mode(struct ov5645 *ov5645, u32 enable)
drivers/media/i2c/ov5645.c
600
u8 val = ov5645->aec_pk_manual;
drivers/media/i2c/ov5645.c
608
ret = ov5645_write_reg(ov5645, OV5645_AEC_PK_MANUAL, val);
drivers/media/i2c/ov5645.c
610
ov5645->aec_pk_manual = val;
drivers/media/i2c/ov5645.c
615
static int ov5645_set_register_array(struct ov5645 *ov5645,
drivers/media/i2c/ov5645.c
623
ret = ov5645_write_reg(ov5645, settings->reg, settings->val);
drivers/media/i2c/ov5645.c
638
struct ov5645 *ov5645 = to_ov5645(sd);
drivers/media/i2c/ov5645.c
640
ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x58);
drivers/media/i2c/ov5645.c
641
gpiod_set_value_cansleep(ov5645->rst_gpio, 1);
drivers/media/i2c/ov5645.c
642
gpiod_set_value_cansleep(ov5645->enable_gpio, 0);
drivers/media/i2c/ov5645.c
643
regulator_bulk_disable(OV5645_NUM_SUPPLIES, ov5645->supplies);
drivers/media/i2c/ov5645.c
649
struct ov5645 *ov5645 = to_ov5645(sd);
drivers/media/i2c/ov5645.c
652
clk_disable_unprepare(ov5645->xclk);
drivers/media/i2c/ov5645.c
660
struct ov5645 *ov5645 = to_ov5645(sd);
drivers/media/i2c/ov5645.c
663
ret = regulator_bulk_enable(OV5645_NUM_SUPPLIES, ov5645->supplies);
drivers/media/i2c/ov5645.c
667
ret = clk_prepare_enable(ov5645->xclk);
drivers/media/i2c/ov5645.c
669
dev_err(ov5645->dev, "clk prepare enable failed\n");
drivers/media/i2c/ov5645.c
670
regulator_bulk_disable(OV5645_NUM_SUPPLIES, ov5645->supplies);
drivers/media/i2c/ov5645.c
675
gpiod_set_value_cansleep(ov5645->enable_gpio, 1);
drivers/media/i2c/ov5645.c
678
gpiod_set_value_cansleep(ov5645->rst_gpio, 0);
drivers/media/i2c/ov5645.c
682
ret = ov5645_set_register_array(ov5645, ov5645_global_init_setting,
drivers/media/i2c/ov5645.c
685
dev_err(ov5645->dev, "could not set init registers\n");
drivers/media/i2c/ov5645.c
695
clk_disable_unprepare(ov5645->xclk);
drivers/media/i2c/ov5645.c
699
static int ov5645_set_saturation(struct ov5645 *ov5645, s32 value)
drivers/media/i2c/ov5645.c
704
ret = ov5645_write_reg(ov5645, OV5645_SDE_SAT_U, reg_value);
drivers/media/i2c/ov5645.c
708
return ov5645_write_reg(ov5645, OV5645_SDE_SAT_V, reg_value);
drivers/media/i2c/ov5645.c
711
static int ov5645_set_hflip(struct ov5645 *ov5645, s32 value)
drivers/media/i2c/ov5645.c
713
u8 val = ov5645->timing_tc_reg21;
drivers/media/i2c/ov5645.c
721
ret = ov5645_write_reg(ov5645, OV5645_TIMING_TC_REG21, val);
drivers/media/i2c/ov5645.c
723
ov5645->timing_tc_reg21 = val;
drivers/media/i2c/ov5645.c
728
static int ov5645_set_vflip(struct ov5645 *ov5645, s32 value)
drivers/media/i2c/ov5645.c
730
u8 val = ov5645->timing_tc_reg20;
drivers/media/i2c/ov5645.c
738
ret = ov5645_write_reg(ov5645, OV5645_TIMING_TC_REG20, val);
drivers/media/i2c/ov5645.c
740
ov5645->timing_tc_reg20 = val;
drivers/media/i2c/ov5645.c
745
static int ov5645_set_test_pattern(struct ov5645 *ov5645, s32 value)
drivers/media/i2c/ov5645.c
754
return ov5645_write_reg(ov5645, OV5645_PRE_ISP_TEST_SETTING_1, val);
drivers/media/i2c/ov5645.c
765
static int ov5645_set_awb(struct ov5645 *ov5645, s32 enable_auto)
drivers/media/i2c/ov5645.c
772
return ov5645_write_reg(ov5645, OV5645_AWB_MANUAL_CONTROL, val);
drivers/media/i2c/ov5645.c
777
struct ov5645 *ov5645 = container_of(ctrl->handler,
drivers/media/i2c/ov5645.c
778
struct ov5645, ctrls);
drivers/media/i2c/ov5645.c
781
if (!pm_runtime_get_if_in_use(ov5645->dev))
drivers/media/i2c/ov5645.c
786
ret = ov5645_set_saturation(ov5645, ctrl->val);
drivers/media/i2c/ov5645.c
789
ret = ov5645_set_awb(ov5645, ctrl->val);
drivers/media/i2c/ov5645.c
792
ret = ov5645_set_agc_mode(ov5645, ctrl->val);
drivers/media/i2c/ov5645.c
795
ret = ov5645_set_aec_mode(ov5645, ctrl->val);
drivers/media/i2c/ov5645.c
798
ret = ov5645_set_test_pattern(ov5645, ctrl->val);
drivers/media/i2c/ov5645.c
801
ret = ov5645_set_hflip(ov5645, ctrl->val);
drivers/media/i2c/ov5645.c
804
ret = ov5645_set_vflip(ov5645, ctrl->val);
drivers/media/i2c/ov5645.c
811
pm_runtime_put_autosuspend(ov5645->dev);
drivers/media/i2c/ov5645.c
854
struct ov5645 *ov5645 = to_ov5645(sd);
drivers/media/i2c/ov5645.c
870
ret = __v4l2_ctrl_s_ctrl_int64(ov5645->pixel_clock,
drivers/media/i2c/ov5645.c
875
ret = __v4l2_ctrl_s_ctrl(ov5645->link_freq,
drivers/media/i2c/ov5645.c
880
ov5645->current_mode = new_mode;
drivers/media/i2c/ov5645.c
928
struct ov5645 *ov5645 = to_ov5645(sd);
drivers/media/i2c/ov5645.c
931
ret = pm_runtime_resume_and_get(ov5645->dev);
drivers/media/i2c/ov5645.c
935
ret = ov5645_set_register_array(ov5645,
drivers/media/i2c/ov5645.c
936
ov5645->current_mode->data,
drivers/media/i2c/ov5645.c
937
ov5645->current_mode->data_size);
drivers/media/i2c/ov5645.c
939
dev_err(ov5645->dev, "could not set mode %dx%d\n",
drivers/media/i2c/ov5645.c
940
ov5645->current_mode->width,
drivers/media/i2c/ov5645.c
941
ov5645->current_mode->height);
drivers/media/i2c/ov5645.c
944
ret = __v4l2_ctrl_handler_setup(&ov5645->ctrls);
drivers/media/i2c/ov5645.c
946
dev_err(ov5645->dev, "could not sync v4l2 controls\n");
drivers/media/i2c/ov5645.c
950
ret = ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x45);
drivers/media/i2c/ov5645.c
954
ret = ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0,
drivers/media/i2c/ov5645.c
962
pm_runtime_put_sync(ov5645->dev);
drivers/media/i2c/ov5645.c
970
struct ov5645 *ov5645 = to_ov5645(sd);
drivers/media/i2c/ov5645.c
973
ret = ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x40);
drivers/media/i2c/ov5645.c
977
ret = ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0,
drivers/media/i2c/ov5645.c
981
pm_runtime_put_autosuspend(ov5645->dev);