Lines Matching refs:hi847

122 #define to_hi847(_sd) container_of(_sd, struct hi847, sd)
2168 struct hi847 { struct
2198 static int hi847_read_reg(struct hi847 *hi847, u16 reg, u16 len, u32 *val) in hi847_read_reg() argument
2200 struct i2c_client *client = v4l2_get_subdevdata(&hi847->sd); in hi847_read_reg()
2228 static int hi847_write_reg(struct hi847 *hi847, u16 reg, u16 len, u32 val) in hi847_write_reg() argument
2230 struct i2c_client *client = v4l2_get_subdevdata(&hi847->sd); in hi847_write_reg()
2244 static int hi847_write_reg_list(struct hi847 *hi847, in hi847_write_reg_list() argument
2247 struct i2c_client *client = v4l2_get_subdevdata(&hi847->sd); in hi847_write_reg_list()
2252 ret = hi847_write_reg(hi847, r_list->regs[i].address, in hi847_write_reg_list()
2266 static int hi847_update_digital_gain(struct hi847 *hi847, u32 d_gain) in hi847_update_digital_gain() argument
2270 ret = hi847_write_reg(hi847, HI847_REG_MWB_GR_GAIN, in hi847_update_digital_gain()
2275 ret = hi847_write_reg(hi847, HI847_REG_MWB_GB_GAIN, in hi847_update_digital_gain()
2280 ret = hi847_write_reg(hi847, HI847_REG_MWB_R_GAIN, in hi847_update_digital_gain()
2285 return hi847_write_reg(hi847, HI847_REG_MWB_B_GAIN, in hi847_update_digital_gain()
2289 static int hi847_test_pattern(struct hi847 *hi847, u32 pattern) in hi847_test_pattern() argument
2295 ret = hi847_read_reg(hi847, HI847_REG_ISP, in hi847_test_pattern()
2300 ret = hi847_write_reg(hi847, HI847_REG_ISP, in hi847_test_pattern()
2307 ret = hi847_read_reg(hi847, HI847_REG_TEST_PATTERN, in hi847_test_pattern()
2312 return hi847_write_reg(hi847, HI847_REG_TEST_PATTERN, in hi847_test_pattern()
2316 static int hi847_grbg_shift(struct hi847 *hi847) in hi847_grbg_shift() argument
2343 hflip = hi847->hflip->val; in hi847_grbg_shift()
2344 vflip = hi847->vflip->val; in hi847_grbg_shift()
2346 if (hi847->cur_mode->width == 3264) { in hi847_grbg_shift()
2347 ret = hi847_write_reg(hi847, HI847_REG_FORMAT_X, in hi847_grbg_shift()
2353 return hi847_write_reg(hi847, HI847_REG_FORMAT_Y, in hi847_grbg_shift()
2357 ret = hi847_write_reg(hi847, HI847_REG_FORMAT_X, in hi847_grbg_shift()
2363 return hi847_write_reg(hi847, HI847_REG_FORMAT_Y, in hi847_grbg_shift()
2369 static int hi847_set_ctrl_hflip(struct hi847 *hi847, u32 ctrl_val) in hi847_set_ctrl_hflip() argument
2374 ret = hi847_read_reg(hi847, HI847_REG_MIRROR_FLIP, in hi847_set_ctrl_hflip()
2379 ret = hi847_grbg_shift(hi847); in hi847_set_ctrl_hflip()
2383 return hi847_write_reg(hi847, HI847_REG_MIRROR_FLIP, in hi847_set_ctrl_hflip()
2388 static int hi847_set_ctrl_vflip(struct hi847 *hi847, u8 ctrl_val) in hi847_set_ctrl_vflip() argument
2393 ret = hi847_read_reg(hi847, HI847_REG_MIRROR_FLIP, in hi847_set_ctrl_vflip()
2398 ret = hi847_grbg_shift(hi847); in hi847_set_ctrl_vflip()
2402 return hi847_write_reg(hi847, HI847_REG_MIRROR_FLIP, in hi847_set_ctrl_vflip()
2409 struct hi847 *hi847 = container_of(ctrl->handler, in hi847_set_ctrl() local
2410 struct hi847, ctrl_handler); in hi847_set_ctrl()
2411 struct i2c_client *client = v4l2_get_subdevdata(&hi847->sd); in hi847_set_ctrl()
2418 exposure_max = hi847->cur_mode->height + ctrl->val - in hi847_set_ctrl()
2420 __v4l2_ctrl_modify_range(hi847->exposure, in hi847_set_ctrl()
2421 hi847->exposure->minimum, in hi847_set_ctrl()
2422 exposure_max, hi847->exposure->step, in hi847_set_ctrl()
2432 ret = hi847_write_reg(hi847, HI847_REG_ANALOG_GAIN, in hi847_set_ctrl()
2437 ret = hi847_update_digital_gain(hi847, ctrl->val); in hi847_set_ctrl()
2441 ret = hi847_write_reg(hi847, HI847_REG_EXPOSURE, in hi847_set_ctrl()
2447 ret = hi847_write_reg(hi847, HI847_REG_FLL, in hi847_set_ctrl()
2449 hi847->cur_mode->height + ctrl->val); in hi847_set_ctrl()
2453 ret = hi847_test_pattern(hi847, ctrl->val); in hi847_set_ctrl()
2457 hi847_set_ctrl_hflip(hi847, ctrl->val); in hi847_set_ctrl()
2461 hi847_set_ctrl_vflip(hi847, ctrl->val); in hi847_set_ctrl()
2478 static int hi847_init_controls(struct hi847 *hi847) in hi847_init_controls() argument
2484 ctrl_hdlr = &hi847->ctrl_handler; in hi847_init_controls()
2489 ctrl_hdlr->lock = &hi847->mutex; in hi847_init_controls()
2490 hi847->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &hi847_ctrl_ops, in hi847_init_controls()
2494 if (hi847->link_freq) in hi847_init_controls()
2495 hi847->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in hi847_init_controls()
2497 hi847->pixel_rate = v4l2_ctrl_new_std in hi847_init_controls()
2503 hi847->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &hi847_ctrl_ops, in hi847_init_controls()
2505 hi847->cur_mode->fll_min - in hi847_init_controls()
2506 hi847->cur_mode->height, in hi847_init_controls()
2508 hi847->cur_mode->height, 1, in hi847_init_controls()
2509 hi847->cur_mode->fll_def - in hi847_init_controls()
2510 hi847->cur_mode->height); in hi847_init_controls()
2512 h_blank = hi847->cur_mode->llp - hi847->cur_mode->width; in hi847_init_controls()
2514 hi847->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &hi847_ctrl_ops, in hi847_init_controls()
2517 if (hi847->hblank) in hi847_init_controls()
2518 hi847->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in hi847_init_controls()
2526 exposure_max = hi847->cur_mode->fll_def - HI847_EXPOSURE_MAX_MARGIN; in hi847_init_controls()
2527 hi847->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &hi847_ctrl_ops, in hi847_init_controls()
2536 hi847->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &hi847_ctrl_ops, in hi847_init_controls()
2538 hi847->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &hi847_ctrl_ops, in hi847_init_controls()
2544 hi847->sd.ctrl_handler = ctrl_hdlr; in hi847_init_controls()
2558 static int hi847_start_streaming(struct hi847 *hi847) in hi847_start_streaming() argument
2560 struct i2c_client *client = v4l2_get_subdevdata(&hi847->sd); in hi847_start_streaming()
2564 link_freq_index = hi847->cur_mode->link_freq_index; in hi847_start_streaming()
2566 ret = hi847_write_reg_list(hi847, reg_list); in hi847_start_streaming()
2572 reg_list = &hi847->cur_mode->reg_list; in hi847_start_streaming()
2573 ret = hi847_write_reg_list(hi847, reg_list); in hi847_start_streaming()
2579 ret = __v4l2_ctrl_handler_setup(hi847->sd.ctrl_handler); in hi847_start_streaming()
2583 ret = hi847_write_reg(hi847, HI847_REG_MODE_TG, in hi847_start_streaming()
2586 ret = hi847_write_reg(hi847, HI847_REG_MODE_SELECT, in hi847_start_streaming()
2597 static void hi847_stop_streaming(struct hi847 *hi847) in hi847_stop_streaming() argument
2599 struct i2c_client *client = v4l2_get_subdevdata(&hi847->sd); in hi847_stop_streaming()
2601 if (hi847_write_reg(hi847, HI847_REG_MODE_TG, in hi847_stop_streaming()
2606 if (hi847_write_reg(hi847, HI847_REG_MODE_SELECT, in hi847_stop_streaming()
2614 struct hi847 *hi847 = to_hi847(sd); in hi847_set_stream() local
2618 mutex_lock(&hi847->mutex); in hi847_set_stream()
2622 mutex_unlock(&hi847->mutex); in hi847_set_stream()
2626 ret = hi847_start_streaming(hi847); in hi847_set_stream()
2629 hi847_stop_streaming(hi847); in hi847_set_stream()
2633 hi847_stop_streaming(hi847); in hi847_set_stream()
2637 mutex_unlock(&hi847->mutex); in hi847_set_stream()
2646 struct hi847 *hi847 = to_hi847(sd); in hi847_set_format() local
2655 mutex_lock(&hi847->mutex); in hi847_set_format()
2661 hi847->cur_mode = mode; in hi847_set_format()
2662 __v4l2_ctrl_s_ctrl(hi847->link_freq, mode->link_freq_index); in hi847_set_format()
2663 __v4l2_ctrl_s_ctrl_int64(hi847->pixel_rate, in hi847_set_format()
2668 __v4l2_ctrl_modify_range(hi847->vblank, in hi847_set_format()
2672 __v4l2_ctrl_s_ctrl(hi847->vblank, vblank_def); in hi847_set_format()
2674 h_blank = hi847->cur_mode->llp - hi847->cur_mode->width; in hi847_set_format()
2676 __v4l2_ctrl_modify_range(hi847->hblank, h_blank, h_blank, 1, in hi847_set_format()
2680 mutex_unlock(&hi847->mutex); in hi847_set_format()
2689 struct hi847 *hi847 = to_hi847(sd); in hi847_get_format() local
2691 mutex_lock(&hi847->mutex); in hi847_get_format()
2696 hi847_assign_pad_format(hi847->cur_mode, &fmt->format); in hi847_get_format()
2698 mutex_unlock(&hi847->mutex); in hi847_get_format()
2735 struct hi847 *hi847 = to_hi847(sd); in hi847_open() local
2737 mutex_lock(&hi847->mutex); in hi847_open()
2740 mutex_unlock(&hi847->mutex); in hi847_open()
2769 static int hi847_identify_module(struct hi847 *hi847) in hi847_identify_module() argument
2771 struct i2c_client *client = v4l2_get_subdevdata(&hi847->sd); in hi847_identify_module()
2775 ret = hi847_read_reg(hi847, HI847_REG_CHIP_ID, in hi847_identify_module()
2860 struct hi847 *hi847 = to_hi847(sd); in hi847_remove() local
2866 mutex_destroy(&hi847->mutex); in hi847_remove()
2871 struct hi847 *hi847; in hi847_probe() local
2874 hi847 = devm_kzalloc(&client->dev, sizeof(*hi847), GFP_KERNEL); in hi847_probe()
2875 if (!hi847) in hi847_probe()
2885 v4l2_i2c_subdev_init(&hi847->sd, client, &hi847_subdev_ops); in hi847_probe()
2886 ret = hi847_identify_module(hi847); in hi847_probe()
2892 mutex_init(&hi847->mutex); in hi847_probe()
2893 hi847->cur_mode = &supported_modes[0]; in hi847_probe()
2894 ret = hi847_init_controls(hi847); in hi847_probe()
2900 hi847->sd.internal_ops = &hi847_internal_ops; in hi847_probe()
2901 hi847->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in hi847_probe()
2902 hi847->sd.entity.ops = &hi847_subdev_entity_ops; in hi847_probe()
2903 hi847->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in hi847_probe()
2904 hi847->pad.flags = MEDIA_PAD_FL_SOURCE; in hi847_probe()
2905 ret = media_entity_pads_init(&hi847->sd.entity, 1, &hi847->pad); in hi847_probe()
2911 ret = v4l2_async_register_subdev_sensor(&hi847->sd); in hi847_probe()
2925 media_entity_cleanup(&hi847->sd.entity); in hi847_probe()
2928 v4l2_ctrl_handler_free(hi847->sd.ctrl_handler); in hi847_probe()
2929 mutex_destroy(&hi847->mutex); in hi847_probe()