Lines Matching full:imx258

603 struct imx258 {  struct
630 static inline struct imx258 *to_imx258(struct v4l2_subdev *_sd) in to_imx258() argument
632 return container_of(_sd, struct imx258, sd); in to_imx258()
636 static int imx258_read_reg(struct imx258 *imx258, u16 reg, u32 len, u32 *val) in imx258_read_reg() argument
638 struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd); in imx258_read_reg()
669 static int imx258_write_reg(struct imx258 *imx258, u16 reg, u32 len, u32 val) in imx258_write_reg() argument
671 struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd); in imx258_write_reg()
686 static int imx258_write_regs(struct imx258 *imx258, in imx258_write_regs() argument
689 struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd); in imx258_write_regs()
694 ret = imx258_write_reg(imx258, regs[i].address, 1, in imx258_write_regs()
724 static int imx258_update_digital_gain(struct imx258 *imx258, u32 len, u32 val) in imx258_update_digital_gain() argument
728 ret = imx258_write_reg(imx258, IMX258_REG_GR_DIGITAL_GAIN, in imx258_update_digital_gain()
733 ret = imx258_write_reg(imx258, IMX258_REG_GB_DIGITAL_GAIN, in imx258_update_digital_gain()
738 ret = imx258_write_reg(imx258, IMX258_REG_R_DIGITAL_GAIN, in imx258_update_digital_gain()
743 ret = imx258_write_reg(imx258, IMX258_REG_B_DIGITAL_GAIN, in imx258_update_digital_gain()
753 struct imx258 *imx258 = in imx258_set_ctrl() local
754 container_of(ctrl->handler, struct imx258, ctrl_handler); in imx258_set_ctrl()
755 struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd); in imx258_set_ctrl()
767 ret = imx258_write_reg(imx258, IMX258_REG_ANALOG_GAIN, in imx258_set_ctrl()
772 ret = imx258_write_reg(imx258, IMX258_REG_EXPOSURE, in imx258_set_ctrl()
777 ret = imx258_update_digital_gain(imx258, IMX258_REG_VALUE_16BIT, in imx258_set_ctrl()
781 ret = imx258_write_reg(imx258, IMX258_REG_TEST_PATTERN, in imx258_set_ctrl()
784 ret = imx258_write_reg(imx258, REG_MIRROR_FLIP_CONTROL, in imx258_set_ctrl()
791 ret = imx258_write_reg(imx258, IMX258_REG_HDR, in imx258_set_ctrl()
795 ret = imx258_write_reg(imx258, IMX258_REG_HDR, in imx258_set_ctrl()
800 ret = imx258_write_reg(imx258, IMX258_REG_HDR_RATIO, in imx258_set_ctrl()
862 static int __imx258_get_pad_format(struct imx258 *imx258, in __imx258_get_pad_format() argument
867 fmt->format = *v4l2_subdev_get_try_format(&imx258->sd, in __imx258_get_pad_format()
871 imx258_update_pad_format(imx258->cur_mode, fmt); in __imx258_get_pad_format()
880 struct imx258 *imx258 = to_imx258(sd); in imx258_get_pad_format() local
883 mutex_lock(&imx258->mutex); in imx258_get_pad_format()
884 ret = __imx258_get_pad_format(imx258, sd_state, fmt); in imx258_get_pad_format()
885 mutex_unlock(&imx258->mutex); in imx258_get_pad_format()
894 struct imx258 *imx258 = to_imx258(sd); in imx258_set_pad_format() local
903 mutex_lock(&imx258->mutex); in imx258_set_pad_format()
916 imx258->cur_mode = mode; in imx258_set_pad_format()
917 __v4l2_ctrl_s_ctrl(imx258->link_freq, mode->link_freq_index); in imx258_set_pad_format()
921 __v4l2_ctrl_s_ctrl_int64(imx258->pixel_rate, pixel_rate); in imx258_set_pad_format()
923 vblank_def = imx258->cur_mode->vts_def - in imx258_set_pad_format()
924 imx258->cur_mode->height; in imx258_set_pad_format()
925 vblank_min = imx258->cur_mode->vts_min - in imx258_set_pad_format()
926 imx258->cur_mode->height; in imx258_set_pad_format()
928 imx258->vblank, vblank_min, in imx258_set_pad_format()
929 IMX258_VTS_MAX - imx258->cur_mode->height, 1, in imx258_set_pad_format()
931 __v4l2_ctrl_s_ctrl(imx258->vblank, vblank_def); in imx258_set_pad_format()
934 - imx258->cur_mode->width; in imx258_set_pad_format()
935 __v4l2_ctrl_modify_range(imx258->hblank, h_blank, in imx258_set_pad_format()
939 mutex_unlock(&imx258->mutex); in imx258_set_pad_format()
945 static int imx258_start_streaming(struct imx258 *imx258) in imx258_start_streaming() argument
947 struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd); in imx258_start_streaming()
952 link_freq_index = imx258->cur_mode->link_freq_index; in imx258_start_streaming()
954 ret = imx258_write_regs(imx258, reg_list->regs, reg_list->num_of_regs); in imx258_start_streaming()
961 reg_list = &imx258->cur_mode->reg_list; in imx258_start_streaming()
962 ret = imx258_write_regs(imx258, reg_list->regs, reg_list->num_of_regs); in imx258_start_streaming()
969 ret = imx258_write_reg(imx258, REG_MIRROR_FLIP_CONTROL, in imx258_start_streaming()
978 ret = __v4l2_ctrl_handler_setup(imx258->sd.ctrl_handler); in imx258_start_streaming()
983 return imx258_write_reg(imx258, IMX258_REG_MODE_SELECT, in imx258_start_streaming()
989 static int imx258_stop_streaming(struct imx258 *imx258) in imx258_stop_streaming() argument
991 struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd); in imx258_stop_streaming()
995 ret = imx258_write_reg(imx258, IMX258_REG_MODE_SELECT, in imx258_stop_streaming()
1010 struct imx258 *imx258 = to_imx258(sd); in imx258_power_on() local
1013 ret = clk_prepare_enable(imx258->clk); in imx258_power_on()
1023 struct imx258 *imx258 = to_imx258(sd); in imx258_power_off() local
1025 clk_disable_unprepare(imx258->clk); in imx258_power_off()
1032 struct imx258 *imx258 = to_imx258(sd); in imx258_set_stream() local
1036 mutex_lock(&imx258->mutex); in imx258_set_stream()
1037 if (imx258->streaming == enable) { in imx258_set_stream()
1038 mutex_unlock(&imx258->mutex); in imx258_set_stream()
1051 ret = imx258_start_streaming(imx258); in imx258_set_stream()
1055 imx258_stop_streaming(imx258); in imx258_set_stream()
1059 imx258->streaming = enable; in imx258_set_stream()
1060 mutex_unlock(&imx258->mutex); in imx258_set_stream()
1067 mutex_unlock(&imx258->mutex); in imx258_set_stream()
1075 struct imx258 *imx258 = to_imx258(sd); in imx258_suspend() local
1077 if (imx258->streaming) in imx258_suspend()
1078 imx258_stop_streaming(imx258); in imx258_suspend()
1086 struct imx258 *imx258 = to_imx258(sd); in imx258_resume() local
1089 if (imx258->streaming) { in imx258_resume()
1090 ret = imx258_start_streaming(imx258); in imx258_resume()
1098 imx258_stop_streaming(imx258); in imx258_resume()
1099 imx258->streaming = 0; in imx258_resume()
1104 static int imx258_identify_module(struct imx258 *imx258) in imx258_identify_module() argument
1106 struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd); in imx258_identify_module()
1110 ret = imx258_read_reg(imx258, IMX258_REG_CHIP_ID, in imx258_identify_module()
1148 static int imx258_init_controls(struct imx258 *imx258) in imx258_init_controls() argument
1150 struct i2c_client *client = v4l2_get_subdevdata(&imx258->sd); in imx258_init_controls()
1158 ctrl_hdlr = &imx258->ctrl_handler; in imx258_init_controls()
1163 mutex_init(&imx258->mutex); in imx258_init_controls()
1164 ctrl_hdlr->lock = &imx258->mutex; in imx258_init_controls()
1165 imx258->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, in imx258_init_controls()
1172 if (imx258->link_freq) in imx258_init_controls()
1173 imx258->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in imx258_init_controls()
1178 imx258->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &imx258_ctrl_ops, in imx258_init_controls()
1184 vblank_def = imx258->cur_mode->vts_def - imx258->cur_mode->height; in imx258_init_controls()
1185 vblank_min = imx258->cur_mode->vts_min - imx258->cur_mode->height; in imx258_init_controls()
1186 imx258->vblank = v4l2_ctrl_new_std( in imx258_init_controls()
1189 IMX258_VTS_MAX - imx258->cur_mode->height, 1, in imx258_init_controls()
1192 if (imx258->vblank) in imx258_init_controls()
1193 imx258->vblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in imx258_init_controls()
1195 imx258->hblank = v4l2_ctrl_new_std( in imx258_init_controls()
1197 IMX258_PPL_DEFAULT - imx258->cur_mode->width, in imx258_init_controls()
1198 IMX258_PPL_DEFAULT - imx258->cur_mode->width, in imx258_init_controls()
1200 IMX258_PPL_DEFAULT - imx258->cur_mode->width); in imx258_init_controls()
1202 if (imx258->hblank) in imx258_init_controls()
1203 imx258->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in imx258_init_controls()
1205 imx258->exposure = v4l2_ctrl_new_std( in imx258_init_controls()
1235 imx258->sd.ctrl_handler = ctrl_hdlr; in imx258_init_controls()
1241 mutex_destroy(&imx258->mutex); in imx258_init_controls()
1246 static void imx258_free_controls(struct imx258 *imx258) in imx258_free_controls() argument
1248 v4l2_ctrl_handler_free(imx258->sd.ctrl_handler); in imx258_free_controls()
1249 mutex_destroy(&imx258->mutex); in imx258_free_controls()
1254 struct imx258 *imx258; in imx258_probe() local
1258 imx258 = devm_kzalloc(&client->dev, sizeof(*imx258), GFP_KERNEL); in imx258_probe()
1259 if (!imx258) in imx258_probe()
1262 imx258->clk = devm_clk_get_optional(&client->dev, NULL); in imx258_probe()
1263 if (IS_ERR(imx258->clk)) in imx258_probe()
1264 return dev_err_probe(&client->dev, PTR_ERR(imx258->clk), in imx258_probe()
1266 if (!imx258->clk) { in imx258_probe()
1272 val = clk_get_rate(imx258->clk); in imx258_probe()
1288 v4l2_i2c_subdev_init(&imx258->sd, client, &imx258_subdev_ops); in imx258_probe()
1296 ret = imx258_identify_module(imx258); in imx258_probe()
1301 imx258->cur_mode = &supported_modes[0]; in imx258_probe()
1303 ret = imx258_init_controls(imx258); in imx258_probe()
1308 imx258->sd.internal_ops = &imx258_internal_ops; in imx258_probe()
1309 imx258->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in imx258_probe()
1310 imx258->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in imx258_probe()
1313 imx258->pad.flags = MEDIA_PAD_FL_SOURCE; in imx258_probe()
1315 ret = media_entity_pads_init(&imx258->sd.entity, 1, &imx258->pad); in imx258_probe()
1319 ret = v4l2_async_register_subdev_sensor(&imx258->sd); in imx258_probe()
1330 media_entity_cleanup(&imx258->sd.entity); in imx258_probe()
1333 imx258_free_controls(imx258); in imx258_probe()
1344 struct imx258 *imx258 = to_imx258(sd); in imx258_remove() local
1348 imx258_free_controls(imx258); in imx258_remove()
1371 { .compatible = "sony,imx258" },
1378 .name = "imx258",
1392 MODULE_DESCRIPTION("Sony IMX258 sensor driver");