Lines Matching refs:gc0329

88 struct gc0329 {  struct
390 static inline struct gc0329 *to_gc0329(struct v4l2_subdev *sd) in to_gc0329()
392 return container_of(sd, struct gc0329, sd); in to_gc0329()
479 static void gc0329_set_streaming(struct gc0329 *gc0329, int on) in gc0329_set_streaming() argument
481 struct i2c_client *client = gc0329->client; in gc0329_set_streaming()
551 struct gc0329 *gc0329 = to_gc0329(sd); in gc0329_get_fmt() local
560 mutex_lock(&gc0329->lock); in gc0329_get_fmt()
562 mutex_unlock(&gc0329->lock); in gc0329_get_fmt()
569 mutex_lock(&gc0329->lock); in gc0329_get_fmt()
570 fmt->format = gc0329->format; in gc0329_get_fmt()
571 mutex_unlock(&gc0329->lock); in gc0329_get_fmt()
574 gc0329->format.code, gc0329->format.width, in gc0329_get_fmt()
575 gc0329->format.height); in gc0329_get_fmt()
629 struct gc0329 *gc0329 = to_gc0329(sd); in gc0329_set_fmt() local
634 __gc0329_try_frame_size_fps(mf, &size, gc0329->fps); in gc0329_set_fmt()
647 mutex_lock(&gc0329->lock); in gc0329_set_fmt()
657 if (gc0329->streaming) { in gc0329_set_fmt()
658 mutex_unlock(&gc0329->lock); in gc0329_set_fmt()
662 gc0329->frame_size = size; in gc0329_set_fmt()
663 gc0329->format = fmt->format; in gc0329_set_fmt()
666 mutex_unlock(&gc0329->lock); in gc0329_set_fmt()
670 static void gc0329_get_module_inf(struct gc0329 *gc0329, in gc0329_get_module_inf() argument
675 strlcpy(inf->base.module, gc0329->module_name, in gc0329_get_module_inf()
677 strlcpy(inf->base.lens, gc0329->len_name, sizeof(inf->base.lens)); in gc0329_get_module_inf()
682 struct gc0329 *gc0329 = to_gc0329(sd); in gc0329_ioctl() local
688 gc0329_get_module_inf(gc0329, (struct rkmodule_inf *)arg); in gc0329_ioctl()
694 gc0329_set_streaming(gc0329, !!stream); in gc0329_ioctl()
756 struct gc0329 *gc0329 = to_gc0329(sd); in gc0329_s_stream() local
761 mutex_lock(&gc0329->lock); in gc0329_s_stream()
765 if (gc0329->streaming == on) in gc0329_s_stream()
770 gc0329_set_streaming(gc0329, on); in gc0329_s_stream()
771 gc0329->streaming = on; in gc0329_s_stream()
772 if (!IS_ERR(gc0329->pwdn_gpio)) { in gc0329_s_stream()
773 gpiod_set_value_cansleep(gc0329->pwdn_gpio, 1); in gc0329_s_stream()
778 if (!IS_ERR(gc0329->pwdn_gpio)) { in gc0329_s_stream()
779 gpiod_set_value_cansleep(gc0329->pwdn_gpio, 0); in gc0329_s_stream()
787 ret = gc0329_write_array(client, gc0329->frame_size->regs); in gc0329_s_stream()
791 gc0329_set_streaming(gc0329, on); in gc0329_s_stream()
792 gc0329->streaming = on; in gc0329_s_stream()
795 mutex_unlock(&gc0329->lock); in gc0329_s_stream()
799 static int gc0329_set_test_pattern(struct gc0329 *gc0329, int value) in gc0329_set_test_pattern() argument
806 struct gc0329 *gc0329 = in gc0329_s_ctrl() local
807 container_of(ctrl->handler, struct gc0329, ctrls); in gc0329_s_ctrl()
811 return gc0329_set_test_pattern(gc0329, ctrl->val); in gc0329_s_ctrl()
859 struct gc0329 *gc0329 = to_gc0329(sd); in gc0329_g_frame_interval() local
861 fi->interval = gc0329->frame_size->max_fps; in gc0329_g_frame_interval()
870 struct gc0329 *gc0329 = to_gc0329(sd); in gc0329_s_frame_interval() local
879 mutex_lock(&gc0329->lock); in gc0329_s_frame_interval()
882 mf = gc0329->format; in gc0329_s_frame_interval()
884 if (gc0329->frame_size != size) { in gc0329_s_frame_interval()
888 gc0329->frame_size = size; in gc0329_s_frame_interval()
889 gc0329->fps = fps; in gc0329_s_frame_interval()
892 mutex_unlock(&gc0329->lock); in gc0329_s_frame_interval()
948 static int gc0329_detect(struct gc0329 *gc0329) in gc0329_detect() argument
950 struct i2c_client *client = gc0329->client; in gc0329_detect()
969 if (!IS_ERR(gc0329->pwdn_gpio)) in gc0329_detect()
970 gpiod_set_value_cansleep(gc0329->pwdn_gpio, 1); in gc0329_detect()
977 static int __gc0329_power_on(struct gc0329 *gc0329) in __gc0329_power_on() argument
980 struct device *dev = &gc0329->client->dev; in __gc0329_power_on()
982 if (!IS_ERR(gc0329->xvclk)) { in __gc0329_power_on()
983 ret = clk_set_rate(gc0329->xvclk, 24000000); in __gc0329_power_on()
988 if (!IS_ERR(gc0329->pwdn_gpio)) { in __gc0329_power_on()
989 gpiod_set_value_cansleep(gc0329->pwdn_gpio, 1); in __gc0329_power_on()
993 if (!IS_ERR(gc0329->supplies)) { in __gc0329_power_on()
995 gc0329->supplies); in __gc0329_power_on()
1002 if (!IS_ERR(gc0329->pwdn_gpio)) { in __gc0329_power_on()
1003 gpiod_set_value_cansleep(gc0329->pwdn_gpio, 0); in __gc0329_power_on()
1007 if (!IS_ERR(gc0329->xvclk)) { in __gc0329_power_on()
1008 ret = clk_prepare_enable(gc0329->xvclk); in __gc0329_power_on()
1018 static void __gc0329_power_off(struct gc0329 *gc0329) in __gc0329_power_off() argument
1020 if (!IS_ERR(gc0329->xvclk)) in __gc0329_power_off()
1021 clk_disable_unprepare(gc0329->xvclk); in __gc0329_power_off()
1022 if (!IS_ERR(gc0329->supplies)) in __gc0329_power_off()
1023 regulator_bulk_disable(GC0329_NUM_SUPPLIES, gc0329->supplies); in __gc0329_power_off()
1024 if (!IS_ERR(gc0329->pwdn_gpio)) in __gc0329_power_off()
1025 gpiod_set_value_cansleep(gc0329->pwdn_gpio, 1); in __gc0329_power_off()
1028 static int gc0329_configure_regulators(struct gc0329 *gc0329) in gc0329_configure_regulators() argument
1033 gc0329->supplies[i].supply = gc0329_supply_names[i]; in gc0329_configure_regulators()
1035 return devm_regulator_bulk_get(&gc0329->client->dev, in gc0329_configure_regulators()
1037 gc0329->supplies); in gc0329_configure_regulators()
1040 static int gc0329_parse_of(struct gc0329 *gc0329) in gc0329_parse_of() argument
1042 struct device *dev = &gc0329->client->dev; in gc0329_parse_of()
1045 gc0329->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in gc0329_parse_of()
1046 if (IS_ERR(gc0329->pwdn_gpio)) in gc0329_parse_of()
1049 ret = gc0329_configure_regulators(gc0329); in gc0329_parse_of()
1053 return __gc0329_power_on(gc0329); in gc0329_parse_of()
1062 struct gc0329 *gc0329; in gc0329_probe() local
1071 gc0329 = devm_kzalloc(&client->dev, sizeof(*gc0329), GFP_KERNEL); in gc0329_probe()
1072 if (!gc0329) in gc0329_probe()
1076 &gc0329->module_index); in gc0329_probe()
1078 &gc0329->module_facing); in gc0329_probe()
1080 &gc0329->module_name); in gc0329_probe()
1082 &gc0329->len_name); in gc0329_probe()
1088 gc0329->client = client; in gc0329_probe()
1089 gc0329->xvclk = devm_clk_get(&client->dev, "xvclk"); in gc0329_probe()
1090 if (IS_ERR(gc0329->xvclk)) { in gc0329_probe()
1095 gc0329_parse_of(gc0329); in gc0329_probe()
1097 gc0329->xvclk_frequency = clk_get_rate(gc0329->xvclk); in gc0329_probe()
1098 if (gc0329->xvclk_frequency < 6000000 || in gc0329_probe()
1099 gc0329->xvclk_frequency > 27000000) in gc0329_probe()
1102 v4l2_ctrl_handler_init(&gc0329->ctrls, 2); in gc0329_probe()
1103 gc0329->link_frequency = in gc0329_probe()
1104 v4l2_ctrl_new_std(&gc0329->ctrls, &gc0329_ctrl_ops, in gc0329_probe()
1109 v4l2_ctrl_new_std_menu_items(&gc0329->ctrls, &gc0329_ctrl_ops, in gc0329_probe()
1113 gc0329->sd.ctrl_handler = &gc0329->ctrls; in gc0329_probe()
1115 if (gc0329->ctrls.error) { in gc0329_probe()
1117 __func__, gc0329->ctrls.error); in gc0329_probe()
1118 return gc0329->ctrls.error; in gc0329_probe()
1121 sd = &gc0329->sd; in gc0329_probe()
1132 gc0329->pad.flags = MEDIA_PAD_FL_SOURCE; in gc0329_probe()
1134 ret = media_entity_pads_init(&sd->entity, 1, &gc0329->pad); in gc0329_probe()
1136 v4l2_ctrl_handler_free(&gc0329->ctrls); in gc0329_probe()
1141 mutex_init(&gc0329->lock); in gc0329_probe()
1143 gc0329_get_default_format(&gc0329->format); in gc0329_probe()
1144 gc0329->frame_size = &gc0329_framesizes[0]; in gc0329_probe()
1145 gc0329->format.width = gc0329_framesizes[0].width; in gc0329_probe()
1146 gc0329->format.height = gc0329_framesizes[0].height; in gc0329_probe()
1147 gc0329->fps = DIV_ROUND_CLOSEST(gc0329_framesizes[0].max_fps.denominator, in gc0329_probe()
1150 ret = gc0329_detect(gc0329); in gc0329_probe()
1155 if (strcmp(gc0329->module_facing, "back") == 0) in gc0329_probe()
1161 gc0329->module_index, facing, in gc0329_probe()
1172 v4l2_ctrl_handler_free(&gc0329->ctrls); in gc0329_probe()
1176 mutex_destroy(&gc0329->lock); in gc0329_probe()
1177 __gc0329_power_off(gc0329); in gc0329_probe()
1184 struct gc0329 *gc0329 = to_gc0329(sd); in gc0329_remove() local
1186 v4l2_ctrl_handler_free(&gc0329->ctrls); in gc0329_remove()
1191 mutex_destroy(&gc0329->lock); in gc0329_remove()
1193 __gc0329_power_off(gc0329); in gc0329_remove()