Lines Matching refs:gc5025
147 struct gc5025 { struct
182 #define to_gc5025(sd) container_of(sd, struct gc5025, subdev) argument
452 struct gc5025 *gc5025 = to_gc5025(sd); in gc5025_set_fmt() local
456 mutex_lock(&gc5025->mutex); in gc5025_set_fmt()
467 mutex_unlock(&gc5025->mutex); in gc5025_set_fmt()
471 gc5025->cur_mode = mode; in gc5025_set_fmt()
473 __v4l2_ctrl_modify_range(gc5025->hblank, h_blank, in gc5025_set_fmt()
476 __v4l2_ctrl_modify_range(gc5025->vblank, vblank_def, in gc5025_set_fmt()
481 mutex_unlock(&gc5025->mutex); in gc5025_set_fmt()
490 struct gc5025 *gc5025 = to_gc5025(sd); in gc5025_get_fmt() local
491 const struct gc5025_mode *mode = gc5025->cur_mode; in gc5025_get_fmt()
493 mutex_lock(&gc5025->mutex); in gc5025_get_fmt()
498 mutex_unlock(&gc5025->mutex); in gc5025_get_fmt()
507 mutex_unlock(&gc5025->mutex); in gc5025_get_fmt()
544 struct gc5025 *gc5025 = to_gc5025(sd); in gc5025_g_frame_interval() local
545 const struct gc5025_mode *mode = gc5025->cur_mode; in gc5025_g_frame_interval()
583 static int gc5025_otp_enable(struct gc5025 *gc5025) in gc5025_otp_enable() argument
585 struct i2c_client *client = gc5025->client; in gc5025_otp_enable()
616 static int gc5025_otp_disable(struct gc5025 *gc5025) in gc5025_otp_disable() argument
618 struct i2c_client *client = gc5025->client; in gc5025_otp_disable()
632 static int gc5025_otp_read(struct gc5025 *gc5025) in gc5025_otp_read() argument
636 struct device *dev = &gc5025->client->dev; in gc5025_otp_read()
637 struct i2c_client *client = gc5025->client; in gc5025_otp_read()
892 gc5025->otp = otp_p; in gc5025_otp_read()
894 gc5025->otp = NULL; in gc5025_otp_read()
941 static void gc5025_get_module_inf(struct gc5025 *gc5025, in gc5025_get_module_inf() argument
944 struct gc5025_otp_info *otp = gc5025->otp; in gc5025_get_module_inf()
950 gc5025->module_name, in gc5025_get_module_inf()
953 gc5025->len_name, in gc5025_get_module_inf()
959 static void gc5025_set_module_inf(struct gc5025 *gc5025, in gc5025_set_module_inf() argument
962 mutex_lock(&gc5025->mutex); in gc5025_set_module_inf()
963 memcpy(&gc5025->awb_cfg, cfg, sizeof(*cfg)); in gc5025_set_module_inf()
964 mutex_unlock(&gc5025->mutex); in gc5025_set_module_inf()
969 struct gc5025 *gc5025 = to_gc5025(sd); in gc5025_ioctl() local
975 gc5025_get_module_inf(gc5025, (struct rkmodule_inf *)arg); in gc5025_ioctl()
978 gc5025_set_module_inf(gc5025, (struct rkmodule_awb_cfg *)arg); in gc5025_ioctl()
985 ret = gc5025_write_reg(gc5025->client, in gc5025_ioctl()
988 ret |= gc5025_write_reg(gc5025->client, in gc5025_ioctl()
992 ret = gc5025_write_reg(gc5025->client, in gc5025_ioctl()
995 ret |= gc5025_write_reg(gc5025->client, in gc5025_ioctl()
1058 static int gc5025_apply_otp(struct gc5025 *gc5025) in gc5025_apply_otp() argument
1061 struct i2c_client *client = gc5025->client; in gc5025_apply_otp()
1062 struct gc5025_otp_info *otp_p = gc5025->otp; in gc5025_apply_otp()
1063 struct rkmodule_awb_cfg *awb_cfg = &gc5025->awb_cfg; in gc5025_apply_otp()
1073 if (!gc5025->awb_cfg.enable) in gc5025_apply_otp()
1247 static int __gc5025_start_stream(struct gc5025 *gc5025) in __gc5025_start_stream() argument
1251 ret = gc5025_write_array(gc5025->client, gc5025->cur_mode->reg_list); in __gc5025_start_stream()
1255 if (gc5025->DR_State) { in __gc5025_start_stream()
1256 ret = gc5025_write_array(gc5025->client, in __gc5025_start_stream()
1259 ret = gc5025_write_array(gc5025->client, in __gc5025_start_stream()
1265 mutex_unlock(&gc5025->mutex); in __gc5025_start_stream()
1266 ret = v4l2_ctrl_handler_setup(&gc5025->ctrl_handler); in __gc5025_start_stream()
1267 mutex_lock(&gc5025->mutex); in __gc5025_start_stream()
1270 if (gc5025->otp) { in __gc5025_start_stream()
1271 ret = gc5025_otp_enable(gc5025); in __gc5025_start_stream()
1272 ret |= gc5025_apply_otp(gc5025); in __gc5025_start_stream()
1273 ret |= gc5025_otp_disable(gc5025); in __gc5025_start_stream()
1277 ret = gc5025_write_reg(gc5025->client, in __gc5025_start_stream()
1280 ret |= gc5025_write_reg(gc5025->client, in __gc5025_start_stream()
1286 static int __gc5025_stop_stream(struct gc5025 *gc5025) in __gc5025_stop_stream() argument
1290 ret = gc5025_write_reg(gc5025->client, in __gc5025_stop_stream()
1293 ret |= gc5025_write_reg(gc5025->client, in __gc5025_stop_stream()
1301 struct gc5025 *gc5025 = to_gc5025(sd); in gc5025_s_stream() local
1302 struct i2c_client *client = gc5025->client; in gc5025_s_stream()
1305 mutex_lock(&gc5025->mutex); in gc5025_s_stream()
1307 if (on == gc5025->streaming) in gc5025_s_stream()
1317 ret = __gc5025_start_stream(gc5025); in gc5025_s_stream()
1324 __gc5025_stop_stream(gc5025); in gc5025_s_stream()
1328 gc5025->streaming = on; in gc5025_s_stream()
1331 mutex_unlock(&gc5025->mutex); in gc5025_s_stream()
1338 struct gc5025 *gc5025 = to_gc5025(sd); in gc5025_s_power() local
1339 struct i2c_client *client = gc5025->client; in gc5025_s_power()
1342 mutex_lock(&gc5025->mutex); in gc5025_s_power()
1345 if (gc5025->power_on == !!on) in gc5025_s_power()
1355 ret = gc5025_write_array(gc5025->client, gc5025_global_regs); in gc5025_s_power()
1362 gc5025->power_on = true; in gc5025_s_power()
1365 gc5025->power_on = false; in gc5025_s_power()
1369 mutex_unlock(&gc5025->mutex); in gc5025_s_power()
1380 static int __gc5025_power_on(struct gc5025 *gc5025) in __gc5025_power_on() argument
1384 struct device *dev = &gc5025->client->dev; in __gc5025_power_on()
1386 if (!IS_ERR(gc5025->power_gpio)) { in __gc5025_power_on()
1387 gpiod_set_value_cansleep(gc5025->power_gpio, 1); in __gc5025_power_on()
1391 if (!IS_ERR_OR_NULL(gc5025->pins_default)) { in __gc5025_power_on()
1392 ret = pinctrl_select_state(gc5025->pinctrl, in __gc5025_power_on()
1393 gc5025->pins_default); in __gc5025_power_on()
1397 ret = clk_set_rate(gc5025->xvclk, GC5025_XVCLK_FREQ); in __gc5025_power_on()
1400 if (clk_get_rate(gc5025->xvclk) != GC5025_XVCLK_FREQ) in __gc5025_power_on()
1402 ret = clk_prepare_enable(gc5025->xvclk); in __gc5025_power_on()
1407 if (!IS_ERR(gc5025->reset_gpio)) in __gc5025_power_on()
1408 gpiod_set_value_cansleep(gc5025->reset_gpio, 1); in __gc5025_power_on()
1410 ret = regulator_bulk_enable(GC5025_NUM_SUPPLIES, gc5025->supplies); in __gc5025_power_on()
1417 if (!IS_ERR(gc5025->reset_gpio)) in __gc5025_power_on()
1418 gpiod_set_value_cansleep(gc5025->reset_gpio, 0); in __gc5025_power_on()
1421 if (!IS_ERR(gc5025->pwdn_gpio)) in __gc5025_power_on()
1422 gpiod_set_value_cansleep(gc5025->pwdn_gpio, 0); in __gc5025_power_on()
1431 clk_disable_unprepare(gc5025->xvclk); in __gc5025_power_on()
1436 static void __gc5025_power_off(struct gc5025 *gc5025) in __gc5025_power_off() argument
1440 if (!IS_ERR(gc5025->pwdn_gpio)) in __gc5025_power_off()
1441 gpiod_set_value_cansleep(gc5025->pwdn_gpio, 1); in __gc5025_power_off()
1442 clk_disable_unprepare(gc5025->xvclk); in __gc5025_power_off()
1443 if (!IS_ERR(gc5025->reset_gpio)) in __gc5025_power_off()
1444 gpiod_set_value_cansleep(gc5025->reset_gpio, 1); in __gc5025_power_off()
1445 if (!IS_ERR_OR_NULL(gc5025->pins_sleep)) { in __gc5025_power_off()
1446 ret = pinctrl_select_state(gc5025->pinctrl, in __gc5025_power_off()
1447 gc5025->pins_sleep); in __gc5025_power_off()
1449 dev_dbg(&gc5025->client->dev, "could not set pins\n"); in __gc5025_power_off()
1451 regulator_bulk_disable(GC5025_NUM_SUPPLIES, gc5025->supplies); in __gc5025_power_off()
1458 struct gc5025 *gc5025 = to_gc5025(sd); in gc5025_runtime_resume() local
1460 return __gc5025_power_on(gc5025); in gc5025_runtime_resume()
1467 struct gc5025 *gc5025 = to_gc5025(sd); in gc5025_runtime_suspend() local
1469 __gc5025_power_off(gc5025); in gc5025_runtime_suspend()
1477 struct gc5025 *gc5025 = to_gc5025(sd); in gc5025_open() local
1482 mutex_lock(&gc5025->mutex); in gc5025_open()
1489 mutex_unlock(&gc5025->mutex); in gc5025_open()
1580 static int gc5025_set_exposure_reg(struct gc5025 *gc5025, u32 exposure) in gc5025_set_exposure_reg() argument
1587 gc5025->Dgain_ratio = 256 * exposure / caltime; in gc5025_set_exposure_reg()
1588 ret = gc5025_write_reg(gc5025->client, in gc5025_set_exposure_reg()
1591 if (!gc5025->DR_State) { in gc5025_set_exposure_reg()
1593 ret |= gc5025_write_reg(gc5025->client, 0xd9, 0xdd); in gc5025_set_exposure_reg()
1595 ret |= gc5025_write_reg(gc5025->client, 0xd9, 0xaa); in gc5025_set_exposure_reg()
1597 ret |= gc5025_write_reg(gc5025->client, in gc5025_set_exposure_reg()
1600 ret |= gc5025_write_reg(gc5025->client, in gc5025_set_exposure_reg()
1609 static int gc5025_set_gain_reg(struct gc5025 *gc5025, u32 a_gain) in gc5025_set_gain_reg() argument
1616 ret = gc5025_write_reg(gc5025->client, in gc5025_set_gain_reg()
1621 ret |= gc5025_write_reg(gc5025->client, in gc5025_set_gain_reg()
1625 ret |= gc5025_write_reg(gc5025->client, in gc5025_set_gain_reg()
1629 temp = temp * gc5025->Dgain_ratio / 256; in gc5025_set_gain_reg()
1630 ret |= gc5025_write_reg(gc5025->client, in gc5025_set_gain_reg()
1633 ret |= gc5025_write_reg(gc5025->client, in gc5025_set_gain_reg()
1641 struct gc5025 *gc5025 = container_of(ctrl->handler, in gc5025_set_ctrl() local
1642 struct gc5025, ctrl_handler); in gc5025_set_ctrl()
1643 struct i2c_client *client = gc5025->client; in gc5025_set_ctrl()
1651 max = gc5025->cur_mode->height + ctrl->val - 4; in gc5025_set_ctrl()
1652 __v4l2_ctrl_modify_range(gc5025->exposure, in gc5025_set_ctrl()
1653 gc5025->exposure->minimum, max, in gc5025_set_ctrl()
1654 gc5025->exposure->step, in gc5025_set_ctrl()
1655 gc5025->exposure->default_value); in gc5025_set_ctrl()
1665 ret = gc5025_set_exposure_reg(gc5025, ctrl->val); in gc5025_set_ctrl()
1668 ret = gc5025_set_gain_reg(gc5025, ctrl->val); in gc5025_set_ctrl()
1671 ret = gc5025_write_reg(gc5025->client, in gc5025_set_ctrl()
1674 ret |= gc5025_write_reg(gc5025->client, in gc5025_set_ctrl()
1677 ret |= gc5025_write_reg(gc5025->client, in gc5025_set_ctrl()
1696 static int gc5025_initialize_controls(struct gc5025 *gc5025) in gc5025_initialize_controls() argument
1705 handler = &gc5025->ctrl_handler; in gc5025_initialize_controls()
1706 mode = gc5025->cur_mode; in gc5025_initialize_controls()
1710 handler->lock = &gc5025->mutex; in gc5025_initialize_controls()
1721 gc5025->hblank = v4l2_ctrl_new_std(handler, NULL, V4L2_CID_HBLANK, in gc5025_initialize_controls()
1723 if (gc5025->hblank) in gc5025_initialize_controls()
1724 gc5025->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in gc5025_initialize_controls()
1727 gc5025->vblank = v4l2_ctrl_new_std(handler, &gc5025_ctrl_ops, in gc5025_initialize_controls()
1733 gc5025->exposure = v4l2_ctrl_new_std(handler, &gc5025_ctrl_ops, in gc5025_initialize_controls()
1738 gc5025->anal_gain = v4l2_ctrl_new_std(handler, &gc5025_ctrl_ops, in gc5025_initialize_controls()
1745 dev_err(&gc5025->client->dev, in gc5025_initialize_controls()
1750 gc5025->subdev.ctrl_handler = handler; in gc5025_initialize_controls()
1760 static int gc5025_check_sensor_id(struct gc5025 *gc5025, in gc5025_check_sensor_id() argument
1763 struct device *dev = &gc5025->client->dev; in gc5025_check_sensor_id()
1783 gc5025->DR_State = false; in gc5025_check_sensor_id()
1786 gc5025->DR_State = false; in gc5025_check_sensor_id()
1789 gc5025->DR_State = true; in gc5025_check_sensor_id()
1796 static int gc5025_configure_regulators(struct gc5025 *gc5025) in gc5025_configure_regulators() argument
1801 gc5025->supplies[i].supply = gc5025_supply_names[i]; in gc5025_configure_regulators()
1803 return devm_regulator_bulk_get(&gc5025->client->dev, in gc5025_configure_regulators()
1805 gc5025->supplies); in gc5025_configure_regulators()
1813 struct gc5025 *gc5025; in gc5025_probe() local
1823 gc5025 = devm_kzalloc(dev, sizeof(*gc5025), GFP_KERNEL); in gc5025_probe()
1824 if (!gc5025) in gc5025_probe()
1828 &gc5025->module_index); in gc5025_probe()
1830 &gc5025->module_facing); in gc5025_probe()
1832 &gc5025->module_name); in gc5025_probe()
1834 &gc5025->len_name); in gc5025_probe()
1839 gc5025->client = client; in gc5025_probe()
1840 gc5025->cur_mode = &supported_modes[0]; in gc5025_probe()
1842 gc5025->xvclk = devm_clk_get(dev, "xvclk"); in gc5025_probe()
1843 if (IS_ERR(gc5025->xvclk)) { in gc5025_probe()
1848 gc5025->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW); in gc5025_probe()
1849 if (IS_ERR(gc5025->power_gpio)) in gc5025_probe()
1852 gc5025->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in gc5025_probe()
1853 if (IS_ERR(gc5025->reset_gpio)) in gc5025_probe()
1856 gc5025->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in gc5025_probe()
1857 if (IS_ERR(gc5025->pwdn_gpio)) in gc5025_probe()
1860 ret = gc5025_configure_regulators(gc5025); in gc5025_probe()
1866 gc5025->pinctrl = devm_pinctrl_get(dev); in gc5025_probe()
1867 if (!IS_ERR(gc5025->pinctrl)) { in gc5025_probe()
1868 gc5025->pins_default = in gc5025_probe()
1869 pinctrl_lookup_state(gc5025->pinctrl, in gc5025_probe()
1871 if (IS_ERR(gc5025->pins_default)) in gc5025_probe()
1874 gc5025->pins_sleep = in gc5025_probe()
1875 pinctrl_lookup_state(gc5025->pinctrl, in gc5025_probe()
1877 if (IS_ERR(gc5025->pins_sleep)) in gc5025_probe()
1881 mutex_init(&gc5025->mutex); in gc5025_probe()
1883 sd = &gc5025->subdev; in gc5025_probe()
1885 ret = gc5025_initialize_controls(gc5025); in gc5025_probe()
1889 ret = __gc5025_power_on(gc5025); in gc5025_probe()
1893 ret = gc5025_check_sensor_id(gc5025, client); in gc5025_probe()
1897 gc5025_otp_enable(gc5025); in gc5025_probe()
1898 gc5025_otp_read(gc5025); in gc5025_probe()
1899 gc5025_otp_disable(gc5025); in gc5025_probe()
1907 gc5025->pad.flags = MEDIA_PAD_FL_SOURCE; in gc5025_probe()
1909 ret = media_entity_pads_init(&sd->entity, 1, &gc5025->pad); in gc5025_probe()
1915 if (strcmp(gc5025->module_facing, "back") == 0) in gc5025_probe()
1921 gc5025->module_index, facing, in gc5025_probe()
1940 __gc5025_power_off(gc5025); in gc5025_probe()
1942 v4l2_ctrl_handler_free(&gc5025->ctrl_handler); in gc5025_probe()
1944 mutex_destroy(&gc5025->mutex); in gc5025_probe()
1952 struct gc5025 *gc5025 = to_gc5025(sd); in gc5025_remove() local
1958 v4l2_ctrl_handler_free(&gc5025->ctrl_handler); in gc5025_remove()
1959 mutex_destroy(&gc5025->mutex); in gc5025_remove()
1963 __gc5025_power_off(gc5025); in gc5025_remove()