Lines Matching refs:gc2145

100 struct gc2145 {  struct
2008 static inline struct gc2145 *to_gc2145(struct v4l2_subdev *sd) in to_gc2145()
2010 return container_of(sd, struct gc2145, sd); in to_gc2145()
2090 static void gc2145_get_default_format(struct gc2145 *gc2145, in gc2145_get_default_format() argument
2093 format->width = gc2145->framesize_cfg[0].width; in gc2145_get_default_format()
2094 format->height = gc2145->framesize_cfg[0].height; in gc2145_get_default_format()
2100 static void gc2145_set_streaming(struct gc2145 *gc2145, int on) in gc2145_set_streaming() argument
2102 struct i2c_client *client = gc2145->client; in gc2145_set_streaming()
2108 if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY) { in gc2145_set_streaming()
2144 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_enum_frame_sizes() local
2150 if (fse->index >= gc2145->cfg_num) in gc2145_enum_frame_sizes()
2159 fse->min_width = gc2145->framesize_cfg[fse->index].width; in gc2145_enum_frame_sizes()
2161 fse->max_height = gc2145->framesize_cfg[fse->index].height; in gc2145_enum_frame_sizes()
2172 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_get_fmt() local
2181 mutex_lock(&gc2145->lock); in gc2145_get_fmt()
2183 mutex_unlock(&gc2145->lock); in gc2145_get_fmt()
2190 mutex_lock(&gc2145->lock); in gc2145_get_fmt()
2191 fmt->format = gc2145->format; in gc2145_get_fmt()
2192 mutex_unlock(&gc2145->lock); in gc2145_get_fmt()
2195 gc2145->format.code, gc2145->format.width, in gc2145_get_fmt()
2196 gc2145->format.height); in gc2145_get_fmt()
2201 static void __gc2145_try_frame_size_fps(struct gc2145 *gc2145, in __gc2145_try_frame_size_fps() argument
2206 const struct gc2145_framesize *fsize = &gc2145->framesize_cfg[0]; in __gc2145_try_frame_size_fps()
2208 unsigned int i = gc2145->cfg_num; in __gc2145_try_frame_size_fps()
2222 match = &gc2145->framesize_cfg[0]; in __gc2145_try_frame_size_fps()
2224 fsize = &gc2145->framesize_cfg[0]; in __gc2145_try_frame_size_fps()
2225 for (i = 0; i < gc2145->cfg_num; i++) { in __gc2145_try_frame_size_fps()
2318 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_set_fmt() local
2322 __gc2145_try_frame_size_fps(gc2145, mf, &size, gc2145->fps); in gc2145_set_fmt()
2335 mutex_lock(&gc2145->lock); in gc2145_set_fmt()
2345 if (gc2145->streaming) { in gc2145_set_fmt()
2346 mutex_unlock(&gc2145->lock); in gc2145_set_fmt()
2350 gc2145->frame_size = size; in gc2145_set_fmt()
2351 gc2145->format = fmt->format; in gc2145_set_fmt()
2356 if (gc2145->power_on) in gc2145_set_fmt()
2359 mutex_unlock(&gc2145->lock); in gc2145_set_fmt()
2367 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_s_stream() local
2372 fps = DIV_ROUND_CLOSEST(gc2145->frame_size->max_fps.denominator, in gc2145_s_stream()
2373 gc2145->frame_size->max_fps.numerator); in gc2145_s_stream()
2376 gc2145->frame_size->width, in gc2145_s_stream()
2377 gc2145->frame_size->height, in gc2145_s_stream()
2378 DIV_ROUND_CLOSEST(gc2145->frame_size->max_fps.denominator, in gc2145_s_stream()
2379 gc2145->frame_size->max_fps.numerator)); in gc2145_s_stream()
2381 mutex_lock(&gc2145->lock); in gc2145_s_stream()
2385 if (gc2145->streaming == on) in gc2145_s_stream()
2390 gc2145_set_streaming(gc2145, on); in gc2145_s_stream()
2391 gc2145->streaming = on; in gc2145_s_stream()
2402 ret = gc2145_write_array(client, gc2145->frame_size->regs); in gc2145_s_stream()
2406 gc2145_set_streaming(gc2145, on); in gc2145_s_stream()
2407 gc2145->streaming = on; in gc2145_s_stream()
2410 mutex_unlock(&gc2145->lock); in gc2145_s_stream()
2414 static int gc2145_set_test_pattern(struct gc2145 *gc2145, int value) in gc2145_set_test_pattern() argument
2421 struct gc2145 *gc2145 = in gc2145_s_ctrl() local
2422 container_of(ctrl->handler, struct gc2145, ctrls); in gc2145_s_ctrl()
2426 return gc2145_set_test_pattern(gc2145, ctrl->val); in gc2145_s_ctrl()
2448 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_open() local
2455 gc2145_get_default_format(gc2145, format); in gc2145_open()
2464 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_g_mbus_config() local
2466 if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY) { in gc2145_g_mbus_config()
2484 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_g_frame_interval() local
2486 fi->interval = gc2145->frame_size->max_fps; in gc2145_g_frame_interval()
2495 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_s_frame_interval() local
2504 mutex_lock(&gc2145->lock); in gc2145_s_frame_interval()
2506 if (gc2145->format.width == 1600) in gc2145_s_frame_interval()
2511 mf = gc2145->format; in gc2145_s_frame_interval()
2512 __gc2145_try_frame_size_fps(gc2145, &mf, &size, fps); in gc2145_s_frame_interval()
2514 if (gc2145->frame_size != size) { in gc2145_s_frame_interval()
2522 gc2145->frame_size = size; in gc2145_s_frame_interval()
2523 gc2145->fps = fps; in gc2145_s_frame_interval()
2526 mutex_unlock(&gc2145->lock); in gc2145_s_frame_interval()
2531 static void gc2145_get_module_inf(struct gc2145 *gc2145, in gc2145_get_module_inf() argument
2536 strlcpy(inf->base.module, gc2145->module_name, in gc2145_get_module_inf()
2538 strlcpy(inf->base.lens, gc2145->len_name, sizeof(inf->base.lens)); in gc2145_get_module_inf()
2543 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_ioctl() local
2549 gc2145_get_module_inf(gc2145, (struct rkmodule_inf *)arg); in gc2145_ioctl()
2555 gc2145_set_streaming(gc2145, !!stream); in gc2145_ioctl()
2624 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_init() local
2625 struct i2c_client *client = gc2145->client; in gc2145_init()
2629 if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY) in gc2145_init()
2640 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_power() local
2641 struct i2c_client *client = gc2145->client; in gc2145_power()
2645 if (!IS_ERR(gc2145->pwdn_gpio)) { in gc2145_power()
2646 gpiod_set_value_cansleep(gc2145->pwdn_gpio, 0); in gc2145_power()
2653 gc2145->power_on = true; in gc2145_power()
2655 if (!IS_ERR(gc2145->pwdn_gpio)) { in gc2145_power()
2656 gpiod_set_value_cansleep(gc2145->pwdn_gpio, 1); in gc2145_power()
2659 gc2145->power_on = false; in gc2145_power()
2668 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_enum_frame_interval() local
2670 if (fie->index >= gc2145->cfg_num) in gc2145_enum_frame_interval()
2674 fie->width = gc2145->framesize_cfg[fie->index].width; in gc2145_enum_frame_interval()
2675 fie->height = gc2145->framesize_cfg[fie->index].height; in gc2145_enum_frame_interval()
2676 fie->interval = gc2145->framesize_cfg[fie->index].max_fps; in gc2145_enum_frame_interval()
2718 static int gc2145_detect(struct gc2145 *gc2145) in gc2145_detect() argument
2720 struct i2c_client *client = gc2145->client; in gc2145_detect()
2742 if (!IS_ERR(gc2145->pwdn_gpio)) in gc2145_detect()
2743 gpiod_set_value_cansleep(gc2145->pwdn_gpio, 1); in gc2145_detect()
2750 static int __gc2145_power_on(struct gc2145 *gc2145) in __gc2145_power_on() argument
2753 struct device *dev = &gc2145->client->dev; in __gc2145_power_on()
2756 if (!IS_ERR(gc2145->power_gpio)) { in __gc2145_power_on()
2757 gpiod_set_value_cansleep(gc2145->power_gpio, 1); in __gc2145_power_on()
2761 if (!IS_ERR(gc2145->reset_gpio)) { in __gc2145_power_on()
2762 gpiod_set_value_cansleep(gc2145->reset_gpio, 0); in __gc2145_power_on()
2764 gpiod_set_value_cansleep(gc2145->reset_gpio, 1); in __gc2145_power_on()
2768 if (!IS_ERR(gc2145->xvclk)) { in __gc2145_power_on()
2769 ret = clk_set_rate(gc2145->xvclk, 24000000); in __gc2145_power_on()
2774 if (!IS_ERR(gc2145->pwdn_gpio)) { in __gc2145_power_on()
2775 gpiod_set_value_cansleep(gc2145->pwdn_gpio, 1); in __gc2145_power_on()
2779 if (!IS_ERR(gc2145->supplies)) { in __gc2145_power_on()
2781 gc2145->supplies); in __gc2145_power_on()
2788 if (!IS_ERR(gc2145->pwdn_gpio)) { in __gc2145_power_on()
2789 gpiod_set_value_cansleep(gc2145->pwdn_gpio, 0); in __gc2145_power_on()
2793 if (!IS_ERR(gc2145->reset_gpio)) { in __gc2145_power_on()
2794 gpiod_set_value_cansleep(gc2145->reset_gpio, 0); in __gc2145_power_on()
2798 if (!IS_ERR(gc2145->xvclk)) { in __gc2145_power_on()
2799 ret = clk_prepare_enable(gc2145->xvclk); in __gc2145_power_on()
2804 gc2145->power_on = true; in __gc2145_power_on()
2808 static void __gc2145_power_off(struct gc2145 *gc2145) in __gc2145_power_off() argument
2810 dev_info(&gc2145->client->dev, "%s(%d)\n", __func__, __LINE__); in __gc2145_power_off()
2811 if (!IS_ERR(gc2145->xvclk)) in __gc2145_power_off()
2812 clk_disable_unprepare(gc2145->xvclk); in __gc2145_power_off()
2813 if (!IS_ERR(gc2145->supplies)) in __gc2145_power_off()
2814 regulator_bulk_disable(GC2145_NUM_SUPPLIES, gc2145->supplies); in __gc2145_power_off()
2815 if (!IS_ERR(gc2145->pwdn_gpio)) in __gc2145_power_off()
2816 gpiod_set_value_cansleep(gc2145->pwdn_gpio, 1); in __gc2145_power_off()
2817 if (!IS_ERR(gc2145->reset_gpio)) in __gc2145_power_off()
2818 gpiod_set_value_cansleep(gc2145->reset_gpio, 0); in __gc2145_power_off()
2819 if (!IS_ERR(gc2145->power_gpio)) in __gc2145_power_off()
2820 gpiod_set_value_cansleep(gc2145->power_gpio, 0); in __gc2145_power_off()
2821 gc2145->power_on = false; in __gc2145_power_off()
2824 static int gc2145_configure_regulators(struct gc2145 *gc2145) in gc2145_configure_regulators() argument
2829 gc2145->supplies[i].supply = gc2145_supply_names[i]; in gc2145_configure_regulators()
2831 return devm_regulator_bulk_get(&gc2145->client->dev, in gc2145_configure_regulators()
2833 gc2145->supplies); in gc2145_configure_regulators()
2836 static int gc2145_parse_of(struct gc2145 *gc2145) in gc2145_parse_of() argument
2838 struct device *dev = &gc2145->client->dev; in gc2145_parse_of()
2849 &gc2145->bus_cfg); in gc2145_parse_of()
2855 if (gc2145->bus_cfg.bus_type == V4L2_MBUS_CSI2_DPHY) { in gc2145_parse_of()
2856 gc2145->framesize_cfg = gc2145_mipi_framesizes; in gc2145_parse_of()
2857 gc2145->cfg_num = ARRAY_SIZE(gc2145_mipi_framesizes); in gc2145_parse_of()
2859 gc2145->framesize_cfg = gc2145_dvp_framesizes; in gc2145_parse_of()
2860 gc2145->cfg_num = ARRAY_SIZE(gc2145_dvp_framesizes); in gc2145_parse_of()
2863 gc2145->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW); in gc2145_parse_of()
2864 if (IS_ERR(gc2145->power_gpio)) in gc2145_parse_of()
2866 gc2145->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in gc2145_parse_of()
2867 if (IS_ERR(gc2145->pwdn_gpio)) in gc2145_parse_of()
2869 gc2145->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); in gc2145_parse_of()
2870 if (IS_ERR(gc2145->reset_gpio)) in gc2145_parse_of()
2873 ret = gc2145_configure_regulators(gc2145); in gc2145_parse_of()
2886 struct gc2145 *gc2145; in gc2145_probe() local
2895 gc2145 = devm_kzalloc(&client->dev, sizeof(*gc2145), GFP_KERNEL); in gc2145_probe()
2896 if (!gc2145) in gc2145_probe()
2900 &gc2145->module_index); in gc2145_probe()
2902 &gc2145->module_facing); in gc2145_probe()
2904 &gc2145->module_name); in gc2145_probe()
2906 &gc2145->len_name); in gc2145_probe()
2912 gc2145->client = client; in gc2145_probe()
2913 gc2145->xvclk = devm_clk_get(&client->dev, "xvclk"); in gc2145_probe()
2914 if (IS_ERR(gc2145->xvclk)) { in gc2145_probe()
2919 ret = gc2145_parse_of(gc2145); in gc2145_probe()
2923 v4l2_ctrl_handler_init(&gc2145->ctrls, 3); in gc2145_probe()
2924 gc2145->link_frequency = in gc2145_probe()
2925 v4l2_ctrl_new_std(&gc2145->ctrls, &gc2145_ctrl_ops, in gc2145_probe()
2930 v4l2_ctrl_new_int_menu(&gc2145->ctrls, NULL, V4L2_CID_LINK_FREQ, in gc2145_probe()
2932 v4l2_ctrl_new_std_menu_items(&gc2145->ctrls, &gc2145_ctrl_ops, in gc2145_probe()
2936 gc2145->sd.ctrl_handler = &gc2145->ctrls; in gc2145_probe()
2938 if (gc2145->ctrls.error) { in gc2145_probe()
2940 __func__, gc2145->ctrls.error); in gc2145_probe()
2941 return gc2145->ctrls.error; in gc2145_probe()
2944 sd = &gc2145->sd; in gc2145_probe()
2955 gc2145->pad.flags = MEDIA_PAD_FL_SOURCE; in gc2145_probe()
2957 ret = media_entity_pads_init(&sd->entity, 1, &gc2145->pad); in gc2145_probe()
2959 v4l2_ctrl_handler_free(&gc2145->ctrls); in gc2145_probe()
2964 mutex_init(&gc2145->lock); in gc2145_probe()
2966 gc2145_get_default_format(gc2145, &gc2145->format); in gc2145_probe()
2967 gc2145->frame_size = &gc2145->framesize_cfg[0]; in gc2145_probe()
2968 gc2145->format.width = gc2145->framesize_cfg[0].width; in gc2145_probe()
2969 gc2145->format.height = gc2145->framesize_cfg[0].height; in gc2145_probe()
2970 gc2145->fps = DIV_ROUND_CLOSEST(gc2145->framesize_cfg[0].max_fps.denominator, in gc2145_probe()
2971 gc2145->framesize_cfg[0].max_fps.numerator); in gc2145_probe()
2973 __gc2145_power_on(gc2145); in gc2145_probe()
2974 gc2145->xvclk_frequency = clk_get_rate(gc2145->xvclk); in gc2145_probe()
2975 if (gc2145->xvclk_frequency < 6000000 || in gc2145_probe()
2976 gc2145->xvclk_frequency > 27000000) in gc2145_probe()
2979 ret = gc2145_detect(gc2145); in gc2145_probe()
2988 if (strcmp(gc2145->module_facing, "back") == 0) in gc2145_probe()
2994 gc2145->module_index, facing, in gc2145_probe()
3001 gc2145->power_on = false; in gc2145_probe()
3005 v4l2_ctrl_handler_free(&gc2145->ctrls); in gc2145_probe()
3009 mutex_destroy(&gc2145->lock); in gc2145_probe()
3010 __gc2145_power_off(gc2145); in gc2145_probe()
3017 struct gc2145 *gc2145 = to_gc2145(sd); in gc2145_remove() local
3019 v4l2_ctrl_handler_free(&gc2145->ctrls); in gc2145_remove()
3024 mutex_destroy(&gc2145->lock); in gc2145_remove()
3026 __gc2145_power_off(gc2145); in gc2145_remove()