Lines Matching refs:gc2035
90 struct gc2035 { struct
779 static inline struct gc2035 *to_gc2035(struct v4l2_subdev *sd) in to_gc2035()
781 return container_of(sd, struct gc2035, sd); in to_gc2035()
868 static void gc2035_set_streaming(struct gc2035 *gc2035, int on) in gc2035_set_streaming() argument
870 struct i2c_client *client = gc2035->client; in gc2035_set_streaming()
941 struct gc2035 *gc2035 = to_gc2035(sd); in gc2035_get_fmt() local
950 mutex_lock(&gc2035->lock); in gc2035_get_fmt()
952 mutex_unlock(&gc2035->lock); in gc2035_get_fmt()
959 mutex_lock(&gc2035->lock); in gc2035_get_fmt()
960 fmt->format = gc2035->format; in gc2035_get_fmt()
961 mutex_unlock(&gc2035->lock); in gc2035_get_fmt()
964 gc2035->format.code, gc2035->format.width, in gc2035_get_fmt()
965 gc2035->format.height); in gc2035_get_fmt()
1019 struct gc2035 *gc2035 = to_gc2035(sd); in gc2035_set_fmt() local
1024 __gc2035_try_frame_size_fps(mf, &size, gc2035->fps); in gc2035_set_fmt()
1037 mutex_lock(&gc2035->lock); in gc2035_set_fmt()
1047 if (gc2035->streaming) { in gc2035_set_fmt()
1048 mutex_unlock(&gc2035->lock); in gc2035_set_fmt()
1052 gc2035->frame_size = size; in gc2035_set_fmt()
1053 gc2035->format = fmt->format; in gc2035_set_fmt()
1056 mutex_unlock(&gc2035->lock); in gc2035_set_fmt()
1063 struct gc2035 *gc2035 = to_gc2035(sd); in gc2035_s_stream() local
1068 mutex_lock(&gc2035->lock); in gc2035_s_stream()
1072 if (gc2035->streaming == on) in gc2035_s_stream()
1077 gc2035_set_streaming(gc2035, on); in gc2035_s_stream()
1078 gc2035->streaming = on; in gc2035_s_stream()
1079 if (!IS_ERR(gc2035->pwdn_gpio)) { in gc2035_s_stream()
1080 gpiod_set_value_cansleep(gc2035->pwdn_gpio, 1); in gc2035_s_stream()
1086 if (!IS_ERR(gc2035->pwdn_gpio)) { in gc2035_s_stream()
1087 gpiod_set_value_cansleep(gc2035->pwdn_gpio, 0); in gc2035_s_stream()
1095 ret = gc2035_write_array(client, gc2035->frame_size->regs); in gc2035_s_stream()
1099 gc2035_set_streaming(gc2035, on); in gc2035_s_stream()
1100 gc2035->streaming = on; in gc2035_s_stream()
1103 mutex_unlock(&gc2035->lock); in gc2035_s_stream()
1107 static int gc2035_set_test_pattern(struct gc2035 *gc2035, int value) in gc2035_set_test_pattern() argument
1114 struct gc2035 *gc2035 = in gc2035_s_ctrl() local
1115 container_of(ctrl->handler, struct gc2035, ctrls); in gc2035_s_ctrl()
1119 return gc2035_set_test_pattern(gc2035, ctrl->val); in gc2035_s_ctrl()
1167 struct gc2035 *gc2035 = to_gc2035(sd); in gc2035_g_frame_interval() local
1169 fi->interval = gc2035->frame_size->max_fps; in gc2035_g_frame_interval()
1178 struct gc2035 *gc2035 = to_gc2035(sd); in gc2035_s_frame_interval() local
1187 mutex_lock(&gc2035->lock); in gc2035_s_frame_interval()
1190 mf = gc2035->format; in gc2035_s_frame_interval()
1192 if (gc2035->frame_size != size) { in gc2035_s_frame_interval()
1196 gc2035->frame_size = size; in gc2035_s_frame_interval()
1197 gc2035->fps = fps; in gc2035_s_frame_interval()
1200 mutex_unlock(&gc2035->lock); in gc2035_s_frame_interval()
1205 static void gc2035_get_module_inf(struct gc2035 *gc2035, in gc2035_get_module_inf() argument
1210 strlcpy(inf->base.module, gc2035->module_name, in gc2035_get_module_inf()
1212 strlcpy(inf->base.lens, gc2035->len_name, sizeof(inf->base.lens)); in gc2035_get_module_inf()
1217 struct gc2035 *gc2035 = to_gc2035(sd); in gc2035_ioctl() local
1223 gc2035_get_module_inf(gc2035, (struct rkmodule_inf *)arg); in gc2035_ioctl()
1229 gc2035_set_streaming(gc2035, !!stream); in gc2035_ioctl()
1339 static int gc2035_detect(struct gc2035 *gc2035) in gc2035_detect() argument
1341 struct i2c_client *client = gc2035->client; in gc2035_detect()
1356 if (!IS_ERR(gc2035->pwdn_gpio)) in gc2035_detect()
1357 gpiod_set_value_cansleep(gc2035->pwdn_gpio, 1); in gc2035_detect()
1369 static int __gc2035_power_on(struct gc2035 *gc2035) in __gc2035_power_on() argument
1372 struct device *dev = &gc2035->client->dev; in __gc2035_power_on()
1374 if (!IS_ERR(gc2035->xvclk)) { in __gc2035_power_on()
1375 ret = clk_set_rate(gc2035->xvclk, 24000000); in __gc2035_power_on()
1380 if (!IS_ERR(gc2035->pwdn_gpio)) { in __gc2035_power_on()
1381 gpiod_set_value_cansleep(gc2035->pwdn_gpio, 1); in __gc2035_power_on()
1385 if (!IS_ERR(gc2035->supplies)) { in __gc2035_power_on()
1387 gc2035->supplies); in __gc2035_power_on()
1394 if (!IS_ERR(gc2035->pwdn_gpio)) { in __gc2035_power_on()
1395 gpiod_set_value_cansleep(gc2035->pwdn_gpio, 0); in __gc2035_power_on()
1399 if (!IS_ERR(gc2035->xvclk)) { in __gc2035_power_on()
1400 ret = clk_prepare_enable(gc2035->xvclk); in __gc2035_power_on()
1410 static void __gc2035_power_off(struct gc2035 *gc2035) in __gc2035_power_off() argument
1412 if (!IS_ERR(gc2035->xvclk)) in __gc2035_power_off()
1413 clk_disable_unprepare(gc2035->xvclk); in __gc2035_power_off()
1414 if (!IS_ERR(gc2035->supplies)) in __gc2035_power_off()
1415 regulator_bulk_disable(GC2035_NUM_SUPPLIES, gc2035->supplies); in __gc2035_power_off()
1416 if (!IS_ERR(gc2035->pwdn_gpio)) in __gc2035_power_off()
1417 gpiod_set_value_cansleep(gc2035->pwdn_gpio, 1); in __gc2035_power_off()
1420 static int gc2035_configure_regulators(struct gc2035 *gc2035) in gc2035_configure_regulators() argument
1425 gc2035->supplies[i].supply = gc2035_supply_names[i]; in gc2035_configure_regulators()
1427 return devm_regulator_bulk_get(&gc2035->client->dev, in gc2035_configure_regulators()
1429 gc2035->supplies); in gc2035_configure_regulators()
1432 static int gc2035_parse_of(struct gc2035 *gc2035) in gc2035_parse_of() argument
1434 struct device *dev = &gc2035->client->dev; in gc2035_parse_of()
1437 gc2035->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in gc2035_parse_of()
1438 if (IS_ERR(gc2035->pwdn_gpio)) in gc2035_parse_of()
1441 ret = gc2035_configure_regulators(gc2035); in gc2035_parse_of()
1445 return __gc2035_power_on(gc2035); in gc2035_parse_of()
1454 struct gc2035 *gc2035; in gc2035_probe() local
1463 gc2035 = devm_kzalloc(&client->dev, sizeof(*gc2035), GFP_KERNEL); in gc2035_probe()
1464 if (!gc2035) in gc2035_probe()
1468 &gc2035->module_index); in gc2035_probe()
1470 &gc2035->module_facing); in gc2035_probe()
1472 &gc2035->module_name); in gc2035_probe()
1474 &gc2035->len_name); in gc2035_probe()
1480 gc2035->client = client; in gc2035_probe()
1481 gc2035->xvclk = devm_clk_get(&client->dev, "xvclk"); in gc2035_probe()
1482 if (IS_ERR(gc2035->xvclk)) { in gc2035_probe()
1487 gc2035_parse_of(gc2035); in gc2035_probe()
1489 gc2035->xvclk_frequency = clk_get_rate(gc2035->xvclk); in gc2035_probe()
1490 if (gc2035->xvclk_frequency < 6000000 || in gc2035_probe()
1491 gc2035->xvclk_frequency > 27000000) in gc2035_probe()
1494 v4l2_ctrl_handler_init(&gc2035->ctrls, 2); in gc2035_probe()
1495 gc2035->link_frequency = in gc2035_probe()
1496 v4l2_ctrl_new_std(&gc2035->ctrls, &gc2035_ctrl_ops, in gc2035_probe()
1501 v4l2_ctrl_new_std_menu_items(&gc2035->ctrls, &gc2035_ctrl_ops, in gc2035_probe()
1505 gc2035->sd.ctrl_handler = &gc2035->ctrls; in gc2035_probe()
1507 if (gc2035->ctrls.error) { in gc2035_probe()
1509 __func__, gc2035->ctrls.error); in gc2035_probe()
1510 return gc2035->ctrls.error; in gc2035_probe()
1513 sd = &gc2035->sd; in gc2035_probe()
1524 gc2035->pad.flags = MEDIA_PAD_FL_SOURCE; in gc2035_probe()
1526 ret = media_entity_pads_init(&sd->entity, 1, &gc2035->pad); in gc2035_probe()
1528 v4l2_ctrl_handler_free(&gc2035->ctrls); in gc2035_probe()
1533 mutex_init(&gc2035->lock); in gc2035_probe()
1535 gc2035_get_default_format(&gc2035->format); in gc2035_probe()
1536 gc2035->frame_size = &gc2035_framesizes[0]; in gc2035_probe()
1537 gc2035->format.width = gc2035_framesizes[0].width; in gc2035_probe()
1538 gc2035->format.height = gc2035_framesizes[0].height; in gc2035_probe()
1539 gc2035->fps = DIV_ROUND_CLOSEST(gc2035_framesizes[0].max_fps.denominator, in gc2035_probe()
1542 ret = gc2035_detect(gc2035); in gc2035_probe()
1547 if (strcmp(gc2035->module_facing, "back") == 0) in gc2035_probe()
1553 gc2035->module_index, facing, in gc2035_probe()
1564 v4l2_ctrl_handler_free(&gc2035->ctrls); in gc2035_probe()
1568 mutex_destroy(&gc2035->lock); in gc2035_probe()
1569 __gc2035_power_off(gc2035); in gc2035_probe()
1576 struct gc2035 *gc2035 = to_gc2035(sd); in gc2035_remove() local
1578 v4l2_ctrl_handler_free(&gc2035->ctrls); in gc2035_remove()
1583 mutex_destroy(&gc2035->lock); in gc2035_remove()
1585 __gc2035_power_off(gc2035); in gc2035_remove()