Lines Matching refs:gc2155
74 struct gc2155 { struct
101 #define to_gc2155(sd) container_of(sd, struct gc2155, subdev) argument
992 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_set_fmt() local
995 mutex_lock(&gc2155->mutex); in gc2155_set_fmt()
1007 mutex_unlock(&gc2155->mutex); in gc2155_set_fmt()
1011 gc2155->cur_mode = mode; in gc2155_set_fmt()
1012 gc2155->format = fmt->format; in gc2155_set_fmt()
1016 if (gc2155->power_on) in gc2155_set_fmt()
1019 mutex_unlock(&gc2155->mutex); in gc2155_set_fmt()
1028 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_get_fmt() local
1029 const struct gc2155_mode *mode = gc2155->cur_mode; in gc2155_get_fmt()
1031 mutex_lock(&gc2155->mutex); in gc2155_get_fmt()
1036 mutex_unlock(&gc2155->mutex); in gc2155_get_fmt()
1046 mutex_unlock(&gc2155->mutex); in gc2155_get_fmt()
1051 static void gc2155_get_default_format(struct gc2155 *gc2155, in gc2155_get_default_format() argument
1054 format->width = gc2155->cur_mode->width; in gc2155_get_default_format()
1055 format->height = gc2155->cur_mode->height; in gc2155_get_default_format()
1092 static int __gc2155_power_on(struct gc2155 *gc2155) in __gc2155_power_on() argument
1095 struct device *dev = &gc2155->client->dev; in __gc2155_power_on()
1098 if (!IS_ERR(gc2155->power_gpio)) { in __gc2155_power_on()
1099 gpiod_set_value_cansleep(gc2155->power_gpio, 1); in __gc2155_power_on()
1103 if (!IS_ERR(gc2155->reset_gpio)) { in __gc2155_power_on()
1104 gpiod_set_value_cansleep(gc2155->reset_gpio, 0); in __gc2155_power_on()
1107 ret = regulator_bulk_enable(GC2155_NUM_SUPPLIES, gc2155->supplies); in __gc2155_power_on()
1113 ret = clk_set_rate(gc2155->xvclk, GC2155_XVCLK_FREQ); in __gc2155_power_on()
1116 if (clk_get_rate(gc2155->xvclk) != GC2155_XVCLK_FREQ) in __gc2155_power_on()
1118 ret = clk_prepare_enable(gc2155->xvclk); in __gc2155_power_on()
1124 if (!IS_ERR(gc2155->pwdn_gpio)) { in __gc2155_power_on()
1125 gpiod_set_value_cansleep(gc2155->pwdn_gpio, 0); in __gc2155_power_on()
1129 if (!IS_ERR(gc2155->reset_gpio)) in __gc2155_power_on()
1130 gpiod_set_value_cansleep(gc2155->reset_gpio, 1); in __gc2155_power_on()
1132 gc2155->power_on = true; in __gc2155_power_on()
1136 static void __gc2155_power_off(struct gc2155 *gc2155) in __gc2155_power_off() argument
1138 if (!IS_ERR(gc2155->reset_gpio)) in __gc2155_power_off()
1139 gpiod_set_value_cansleep(gc2155->reset_gpio, 0); in __gc2155_power_off()
1140 if (!IS_ERR(gc2155->pwdn_gpio)) in __gc2155_power_off()
1141 gpiod_set_value_cansleep(gc2155->pwdn_gpio, 1); in __gc2155_power_off()
1143 if (!IS_ERR(gc2155->xvclk)) in __gc2155_power_off()
1144 clk_disable_unprepare(gc2155->xvclk); in __gc2155_power_off()
1145 if (!IS_ERR(gc2155->power_gpio)) in __gc2155_power_off()
1146 gpiod_set_value_cansleep(gc2155->power_gpio, 0); in __gc2155_power_off()
1147 regulator_bulk_disable(GC2155_NUM_SUPPLIES, gc2155->supplies); in __gc2155_power_off()
1148 gc2155->power_on = false; in __gc2155_power_off()
1151 static void gc2155_get_module_inf(struct gc2155 *gc2155, in gc2155_get_module_inf() argument
1156 strlcpy(inf->base.module, gc2155->module_name, in gc2155_get_module_inf()
1158 strlcpy(inf->base.lens, gc2155->len_name, sizeof(inf->base.lens)); in gc2155_get_module_inf()
1163 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_ioctl() local
1168 gc2155_get_module_inf(gc2155, (struct rkmodule_inf *)arg); in gc2155_ioctl()
1223 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_s_stream() local
1224 struct i2c_client *client = gc2155->client; in gc2155_s_stream()
1230 fps = DIV_ROUND_CLOSEST(gc2155->cur_mode->max_fps.denominator, in gc2155_s_stream()
1231 gc2155->cur_mode->max_fps.numerator); in gc2155_s_stream()
1234 gc2155->cur_mode->width, in gc2155_s_stream()
1235 gc2155->cur_mode->height, in gc2155_s_stream()
1238 mutex_lock(&gc2155->mutex); in gc2155_s_stream()
1241 if (on == gc2155->streaming) in gc2155_s_stream()
1245 ret = pm_runtime_get_sync(&gc2155->client->dev); in gc2155_s_stream()
1251 ret = gc2155_write_array(gc2155->client, in gc2155_s_stream()
1252 gc2155->cur_mode->reg_list); in gc2155_s_stream()
1263 gc2155->streaming = on; in gc2155_s_stream()
1274 mutex_unlock(&gc2155->mutex); in gc2155_s_stream()
1281 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_s_power() local
1282 struct i2c_client *client = gc2155->client; in gc2155_s_power()
1285 mutex_lock(&gc2155->mutex); in gc2155_s_power()
1288 if (gc2155->power_on == !!on) in gc2155_s_power()
1298 ret = gc2155_write_array(gc2155->client, gc2155_global_regs); in gc2155_s_power()
1305 gc2155->power_on = true; in gc2155_s_power()
1308 gc2155->power_on = false; in gc2155_s_power()
1312 mutex_unlock(&gc2155->mutex); in gc2155_s_power()
1317 static int gc2155_set_test_pattern(struct gc2155 *gc2155, int value) in gc2155_set_test_pattern() argument
1324 struct gc2155 *gc2155 = in gc2155_s_ctrl() local
1325 container_of(ctrl->handler, struct gc2155, ctrls); in gc2155_s_ctrl()
1329 return gc2155_set_test_pattern(gc2155, ctrl->val); in gc2155_s_ctrl()
1347 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_open() local
1352 mutex_lock(&gc2155->mutex); in gc2155_open()
1360 mutex_unlock(&gc2155->mutex); in gc2155_open()
1370 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_runtime_resume() local
1372 return __gc2155_power_on(gc2155); in gc2155_runtime_resume()
1379 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_runtime_suspend() local
1381 __gc2155_power_off(gc2155); in gc2155_runtime_suspend()
1400 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_g_frame_interval() local
1402 fi->interval = gc2155->cur_mode->max_fps; in gc2155_g_frame_interval()
1407 static void __gc2155_try_frame_size_fps(struct gc2155 *gc2155, in __gc2155_try_frame_size_fps() argument
1412 const struct gc2155_mode *fsize = &gc2155->framesize_cfg[0]; in __gc2155_try_frame_size_fps()
1414 unsigned int i = gc2155->cfg_num; in __gc2155_try_frame_size_fps()
1428 match = &gc2155->framesize_cfg[0]; in __gc2155_try_frame_size_fps()
1430 fsize = &gc2155->framesize_cfg[0]; in __gc2155_try_frame_size_fps()
1431 for (i = 0; i < gc2155->cfg_num; i++) { in __gc2155_try_frame_size_fps()
1452 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_s_frame_interval() local
1461 mutex_lock(&gc2155->mutex); in gc2155_s_frame_interval()
1462 if (gc2155->cur_mode->width == 1600) in gc2155_s_frame_interval()
1466 mf = gc2155->format; in gc2155_s_frame_interval()
1467 __gc2155_try_frame_size_fps(gc2155, &mf, &mode, fps); in gc2155_s_frame_interval()
1468 if (gc2155->cur_mode != mode) { in gc2155_s_frame_interval()
1472 gc2155->cur_mode = mode; in gc2155_s_frame_interval()
1473 gc2155->fps = fps; in gc2155_s_frame_interval()
1476 mutex_unlock(&gc2155->mutex); in gc2155_s_frame_interval()
1538 static int gc2155_check_sensor_id(struct gc2155 *gc2155, in gc2155_check_sensor_id() argument
1541 struct device *dev = &gc2155->client->dev; in gc2155_check_sensor_id()
1558 static int gc2155_configure_regulators(struct gc2155 *gc2155) in gc2155_configure_regulators() argument
1563 gc2155->supplies[i].supply = gc2155_supply_names[i]; in gc2155_configure_regulators()
1565 return devm_regulator_bulk_get(&gc2155->client->dev, in gc2155_configure_regulators()
1567 gc2155->supplies); in gc2155_configure_regulators()
1575 struct gc2155 *gc2155; in gc2155_probe() local
1585 gc2155 = devm_kzalloc(dev, sizeof(*gc2155), GFP_KERNEL); in gc2155_probe()
1586 if (!gc2155) in gc2155_probe()
1590 &gc2155->module_index); in gc2155_probe()
1592 &gc2155->module_facing); in gc2155_probe()
1594 &gc2155->module_name); in gc2155_probe()
1596 &gc2155->len_name); in gc2155_probe()
1602 gc2155->client = client; in gc2155_probe()
1603 gc2155->cur_mode = &supported_modes[0]; in gc2155_probe()
1604 gc2155_get_default_format(gc2155, &gc2155->format); in gc2155_probe()
1605 gc2155->format.width = gc2155->cur_mode->width; in gc2155_probe()
1606 gc2155->format.height = gc2155->cur_mode->height; in gc2155_probe()
1607 gc2155->fps = DIV_ROUND_CLOSEST(gc2155->cur_mode->max_fps.denominator, in gc2155_probe()
1608 gc2155->cur_mode->max_fps.numerator); in gc2155_probe()
1609 gc2155->framesize_cfg = supported_modes; in gc2155_probe()
1610 gc2155->cfg_num = ARRAY_SIZE(supported_modes); in gc2155_probe()
1612 gc2155->xvclk = devm_clk_get(dev, "xvclk"); in gc2155_probe()
1613 if (IS_ERR(gc2155->xvclk)) { in gc2155_probe()
1617 gc2155->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW); in gc2155_probe()
1618 if (IS_ERR(gc2155->power_gpio)) in gc2155_probe()
1621 gc2155->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in gc2155_probe()
1622 if (IS_ERR(gc2155->reset_gpio)) in gc2155_probe()
1625 gc2155->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in gc2155_probe()
1626 if (IS_ERR(gc2155->pwdn_gpio)) in gc2155_probe()
1629 ret = gc2155_configure_regulators(gc2155); in gc2155_probe()
1634 v4l2_ctrl_handler_init(&gc2155->ctrls, 2); in gc2155_probe()
1635 gc2155->pixel_rate = in gc2155_probe()
1636 v4l2_ctrl_new_std(&gc2155->ctrls, &gc2155_ctrl_ops, in gc2155_probe()
1641 v4l2_ctrl_new_std_menu_items(&gc2155->ctrls, &gc2155_ctrl_ops, in gc2155_probe()
1645 gc2155->subdev.ctrl_handler = &gc2155->ctrls; in gc2155_probe()
1647 if (gc2155->ctrls.error) { in gc2155_probe()
1649 __func__, gc2155->ctrls.error); in gc2155_probe()
1650 return gc2155->ctrls.error; in gc2155_probe()
1653 mutex_init(&gc2155->mutex); in gc2155_probe()
1654 v4l2_i2c_subdev_init(&gc2155->subdev, client, &gc2155_subdev_ops); in gc2155_probe()
1656 ret = __gc2155_power_on(gc2155); in gc2155_probe()
1660 ret = gc2155_check_sensor_id(gc2155, client); in gc2155_probe()
1665 gc2155->subdev.internal_ops = &gc2155_internal_ops; in gc2155_probe()
1666 gc2155->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in gc2155_probe()
1669 gc2155->pad.flags = MEDIA_PAD_FL_SOURCE; in gc2155_probe()
1670 gc2155->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR; in gc2155_probe()
1671 ret = media_entity_pads_init(&gc2155->subdev.entity, 1, &gc2155->pad); in gc2155_probe()
1676 sd = &gc2155->subdev; in gc2155_probe()
1678 if (strcmp(gc2155->module_facing, "back") == 0) in gc2155_probe()
1684 gc2155->module_index, facing, in gc2155_probe()
1700 media_entity_cleanup(&gc2155->subdev.entity); in gc2155_probe()
1703 __gc2155_power_off(gc2155); in gc2155_probe()
1705 mutex_destroy(&gc2155->mutex); in gc2155_probe()
1706 v4l2_ctrl_handler_free(&gc2155->ctrls); in gc2155_probe()
1713 struct gc2155 *gc2155 = to_gc2155(sd); in gc2155_remove() local
1719 mutex_destroy(&gc2155->mutex); in gc2155_remove()
1723 __gc2155_power_off(gc2155); in gc2155_remove()