Lines Matching refs:bf3925

96 struct bf3925 {  struct
616 static inline struct bf3925 *to_bf3925(struct v4l2_subdev *sd) in to_bf3925()
618 return container_of(sd, struct bf3925, sd); in to_bf3925()
706 static void bf3925_set_streaming(struct bf3925 *bf3925, int on) in bf3925_set_streaming() argument
708 struct i2c_client *client = bf3925->client; in bf3925_set_streaming()
769 struct bf3925 *bf3925 = to_bf3925(sd); in bf3925_get_fmt() local
778 mutex_lock(&bf3925->lock); in bf3925_get_fmt()
780 mutex_unlock(&bf3925->lock); in bf3925_get_fmt()
787 mutex_lock(&bf3925->lock); in bf3925_get_fmt()
788 fmt->format = bf3925->format; in bf3925_get_fmt()
789 mutex_unlock(&bf3925->lock); in bf3925_get_fmt()
792 bf3925->format.code, bf3925->format.width, in bf3925_get_fmt()
793 bf3925->format.height); in bf3925_get_fmt()
847 struct bf3925 *bf3925 = to_bf3925(sd); in bf3925_set_fmt() local
852 __bf3925_try_frame_size_fps(mf, &size, bf3925->fps); in bf3925_set_fmt()
865 mutex_lock(&bf3925->lock); in bf3925_set_fmt()
875 if (bf3925->streaming) { in bf3925_set_fmt()
876 mutex_unlock(&bf3925->lock); in bf3925_set_fmt()
880 bf3925->frame_size = size; in bf3925_set_fmt()
881 bf3925->format = fmt->format; in bf3925_set_fmt()
884 mutex_unlock(&bf3925->lock); in bf3925_set_fmt()
891 struct bf3925 *bf3925 = to_bf3925(sd); in bf3925_s_stream() local
895 bf3925->frame_size->width, in bf3925_s_stream()
896 bf3925->frame_size->height); in bf3925_s_stream()
898 mutex_lock(&bf3925->lock); in bf3925_s_stream()
902 if (bf3925->streaming == on) in bf3925_s_stream()
907 bf3925_set_streaming(bf3925, 0x02); in bf3925_s_stream()
908 bf3925->streaming = on; in bf3925_s_stream()
912 ret = bf3925_write_array(client, bf3925->frame_size->regs); in bf3925_s_stream()
916 bf3925_set_streaming(bf3925, 0x00); in bf3925_s_stream()
917 bf3925->streaming = on; in bf3925_s_stream()
920 mutex_unlock(&bf3925->lock); in bf3925_s_stream()
924 static int bf3925_set_test_pattern(struct bf3925 *bf3925, int value) in bf3925_set_test_pattern() argument
931 struct bf3925 *bf3925 = in bf3925_s_ctrl() local
932 container_of(ctrl->handler, struct bf3925, ctrls); in bf3925_s_ctrl()
936 return bf3925_set_test_pattern(bf3925, ctrl->val); in bf3925_s_ctrl()
984 struct bf3925 *bf3925 = to_bf3925(sd); in bf3925_g_frame_interval() local
986 mutex_lock(&bf3925->lock); in bf3925_g_frame_interval()
987 fi->interval = bf3925->frame_size->max_fps; in bf3925_g_frame_interval()
988 mutex_unlock(&bf3925->lock); in bf3925_g_frame_interval()
997 struct bf3925 *bf3925 = to_bf3925(sd); in bf3925_s_frame_interval() local
1006 mutex_lock(&bf3925->lock); in bf3925_s_frame_interval()
1007 if (bf3925->format.width == 1600) in bf3925_s_frame_interval()
1011 mf = bf3925->format; in bf3925_s_frame_interval()
1014 if (bf3925->frame_size != size) { in bf3925_s_frame_interval()
1022 bf3925->frame_size = size; in bf3925_s_frame_interval()
1023 bf3925->fps = fps; in bf3925_s_frame_interval()
1026 mutex_unlock(&bf3925->lock); in bf3925_s_frame_interval()
1031 static void bf3925_get_module_inf(struct bf3925 *bf3925, in bf3925_get_module_inf() argument
1036 strlcpy(inf->base.module, bf3925->module_name, in bf3925_get_module_inf()
1038 strlcpy(inf->base.lens, bf3925->len_name, sizeof(inf->base.lens)); in bf3925_get_module_inf()
1043 struct bf3925 *bf3925 = to_bf3925(sd); in bf3925_ioctl() local
1049 bf3925_get_module_inf(bf3925, (struct rkmodule_inf *)arg); in bf3925_ioctl()
1054 bf3925_set_streaming(bf3925, 0x00); in bf3925_ioctl()
1056 bf3925_set_streaming(bf3925, 0x02); in bf3925_ioctl()
1118 struct bf3925 *bf3925 = to_bf3925(sd); in bf3925_init() local
1119 struct i2c_client *client = bf3925->client; in bf3925_init()
1131 struct bf3925 *bf3925 = to_bf3925(sd); in bf3925_power() local
1132 struct i2c_client *client = bf3925->client; in bf3925_power()
1133 struct device *dev = &bf3925->client->dev; in bf3925_power()
1137 if (!IS_ERR(bf3925->pwdn_gpio)) { in bf3925_power()
1138 gpiod_set_value_cansleep(bf3925->pwdn_gpio, 0); in bf3925_power()
1146 if (!IS_ERR(bf3925->pwdn_gpio)) { in bf3925_power()
1147 gpiod_set_value_cansleep(bf3925->pwdn_gpio, 1); in bf3925_power()
1208 static int bf3925_detect(struct bf3925 *bf3925) in bf3925_detect() argument
1210 struct i2c_client *client = bf3925->client; in bf3925_detect()
1232 if (!IS_ERR(bf3925->pwdn_gpio)) in bf3925_detect()
1233 gpiod_set_value_cansleep(bf3925->pwdn_gpio, 1); in bf3925_detect()
1240 static int __bf3925_power_on(struct bf3925 *bf3925) in __bf3925_power_on() argument
1243 struct device *dev = &bf3925->client->dev; in __bf3925_power_on()
1246 if (!IS_ERR(bf3925->xvclk)) { in __bf3925_power_on()
1247 ret = clk_set_rate(bf3925->xvclk, 24000000); in __bf3925_power_on()
1251 if (!IS_ERR(bf3925->xvclk)) { in __bf3925_power_on()
1252 ret = clk_prepare_enable(bf3925->xvclk); in __bf3925_power_on()
1258 if (!IS_ERR(bf3925->pwdn_gpio)) { in __bf3925_power_on()
1259 gpiod_set_value_cansleep(bf3925->pwdn_gpio, 1); in __bf3925_power_on()
1263 if (!IS_ERR(bf3925->supplies)) { in __bf3925_power_on()
1265 bf3925->supplies); in __bf3925_power_on()
1272 if (!IS_ERR(bf3925->pwdn2_gpio)) { in __bf3925_power_on()
1273 gpiod_set_value_cansleep(bf3925->pwdn2_gpio, 1); in __bf3925_power_on()
1277 if (!IS_ERR(bf3925->pwdn_gpio)) { in __bf3925_power_on()
1278 gpiod_set_value_cansleep(bf3925->pwdn_gpio, 0); in __bf3925_power_on()
1285 static void __bf3925_power_off(struct bf3925 *bf3925) in __bf3925_power_off() argument
1287 if (!IS_ERR(bf3925->xvclk)) in __bf3925_power_off()
1288 clk_disable_unprepare(bf3925->xvclk); in __bf3925_power_off()
1289 if (!IS_ERR(bf3925->supplies)) in __bf3925_power_off()
1290 regulator_bulk_disable(BF3925_NUM_SUPPLIES, bf3925->supplies); in __bf3925_power_off()
1291 if (!IS_ERR(bf3925->pwdn_gpio)) in __bf3925_power_off()
1292 gpiod_set_value_cansleep(bf3925->pwdn_gpio, 1); in __bf3925_power_off()
1295 static int bf3925_configure_regulators(struct bf3925 *bf3925) in bf3925_configure_regulators() argument
1300 bf3925->supplies[i].supply = bf3925_supply_names[i]; in bf3925_configure_regulators()
1302 return devm_regulator_bulk_get(&bf3925->client->dev, in bf3925_configure_regulators()
1304 bf3925->supplies); in bf3925_configure_regulators()
1307 static int bf3925_parse_of(struct bf3925 *bf3925) in bf3925_parse_of() argument
1309 struct device *dev = &bf3925->client->dev; in bf3925_parse_of()
1316 bf3925->pwdn_gpio = devm_gpiod_get(dev, "pwdn", GPIOD_OUT_LOW); in bf3925_parse_of()
1317 if (IS_ERR(bf3925->pwdn_gpio)) { in bf3925_parse_of()
1324 bf3925->pwdn_gpio = pwdn_gpio; in bf3925_parse_of()
1327 bf3925->pwdn2_gpio = devm_gpiod_get(dev, "pwdn2", GPIOD_OUT_LOW); in bf3925_parse_of()
1328 if (IS_ERR(bf3925->pwdn2_gpio)) { in bf3925_parse_of()
1335 bf3925->pwdn2_gpio = pwdn_gpio; in bf3925_parse_of()
1338 ret = bf3925_configure_regulators(bf3925); in bf3925_parse_of()
1342 return __bf3925_power_on(bf3925); in bf3925_parse_of()
1351 struct bf3925 *bf3925; in bf3925_probe() local
1360 bf3925 = devm_kzalloc(&client->dev, sizeof(*bf3925), GFP_KERNEL); in bf3925_probe()
1361 if (!bf3925) in bf3925_probe()
1365 &bf3925->module_index); in bf3925_probe()
1367 &bf3925->module_facing); in bf3925_probe()
1369 &bf3925->module_name); in bf3925_probe()
1371 &bf3925->len_name); in bf3925_probe()
1377 bf3925->client = client; in bf3925_probe()
1378 bf3925->xvclk = devm_clk_get(&client->dev, "xvclk"); in bf3925_probe()
1379 if (IS_ERR(bf3925->xvclk)) { in bf3925_probe()
1384 bf3925_parse_of(bf3925); in bf3925_probe()
1386 bf3925->xvclk_frequency = clk_get_rate(bf3925->xvclk); in bf3925_probe()
1387 if (bf3925->xvclk_frequency < 6000000 || in bf3925_probe()
1388 bf3925->xvclk_frequency > 27000000) in bf3925_probe()
1391 v4l2_ctrl_handler_init(&bf3925->ctrls, 2); in bf3925_probe()
1392 bf3925->link_frequency = in bf3925_probe()
1393 v4l2_ctrl_new_std(&bf3925->ctrls, &bf3925_ctrl_ops, in bf3925_probe()
1398 v4l2_ctrl_new_std_menu_items(&bf3925->ctrls, &bf3925_ctrl_ops, in bf3925_probe()
1402 bf3925->sd.ctrl_handler = &bf3925->ctrls; in bf3925_probe()
1404 if (bf3925->ctrls.error) { in bf3925_probe()
1406 __func__, bf3925->ctrls.error); in bf3925_probe()
1407 return bf3925->ctrls.error; in bf3925_probe()
1410 sd = &bf3925->sd; in bf3925_probe()
1421 bf3925->pad.flags = MEDIA_PAD_FL_SOURCE; in bf3925_probe()
1423 ret = media_entity_pads_init(&sd->entity, 1, &bf3925->pad); in bf3925_probe()
1425 v4l2_ctrl_handler_free(&bf3925->ctrls); in bf3925_probe()
1430 mutex_init(&bf3925->lock); in bf3925_probe()
1432 bf3925_get_default_format(&bf3925->format); in bf3925_probe()
1433 bf3925->frame_size = &bf3925_framesizes[0]; in bf3925_probe()
1434 bf3925->format.width = bf3925_framesizes[0].width; in bf3925_probe()
1435 bf3925->format.height = bf3925_framesizes[0].height; in bf3925_probe()
1436 bf3925->fps = DIV_ROUND_CLOSEST(bf3925_framesizes[0].max_fps.denominator, in bf3925_probe()
1439 ret = bf3925_detect(bf3925); in bf3925_probe()
1444 if (strcmp(bf3925->module_facing, "back") == 0) in bf3925_probe()
1450 bf3925->module_index, facing, in bf3925_probe()
1452 ret = v4l2_async_register_subdev_sensor_common(&bf3925->sd); in bf3925_probe()
1461 v4l2_ctrl_handler_free(&bf3925->ctrls); in bf3925_probe()
1465 mutex_destroy(&bf3925->lock); in bf3925_probe()
1466 __bf3925_power_off(bf3925); in bf3925_probe()
1473 struct bf3925 *bf3925 = to_bf3925(sd); in bf3925_remove() local
1475 v4l2_ctrl_handler_free(&bf3925->ctrls); in bf3925_remove()
1480 mutex_destroy(&bf3925->lock); in bf3925_remove()
1482 __bf3925_power_off(bf3925); in bf3925_remove()