Lines Matching refs:imx355
100 struct imx355 { struct
1062 static inline struct imx355 *to_imx355(struct v4l2_subdev *_sd) in to_imx355()
1064 return container_of(_sd, struct imx355, sd); in to_imx355()
1068 static u32 imx355_get_format_code(struct imx355 *imx355) in imx355_get_format_code() argument
1080 lockdep_assert_held(&imx355->mutex); in imx355_get_format_code()
1081 code = codes[imx355->vflip->val][imx355->hflip->val]; in imx355_get_format_code()
1087 static int imx355_read_reg(struct imx355 *imx355, u16 reg, u32 len, u32 *val) in imx355_read_reg() argument
1089 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_read_reg()
1121 static int imx355_write_reg(struct imx355 *imx355, u16 reg, u32 len, u32 val) in imx355_write_reg() argument
1123 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_write_reg()
1138 static int imx355_write_regs(struct imx355 *imx355, in imx355_write_regs() argument
1141 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_write_regs()
1146 ret = imx355_write_reg(imx355, regs[i].address, 1, regs[i].val); in imx355_write_regs()
1162 struct imx355 *imx355 = to_imx355(sd); in imx355_open() local
1166 mutex_lock(&imx355->mutex); in imx355_open()
1169 try_fmt->width = imx355->cur_mode->width; in imx355_open()
1170 try_fmt->height = imx355->cur_mode->height; in imx355_open()
1171 try_fmt->code = imx355_get_format_code(imx355); in imx355_open()
1174 mutex_unlock(&imx355->mutex); in imx355_open()
1181 struct imx355 *imx355 = container_of(ctrl->handler, in imx355_set_ctrl() local
1182 struct imx355, ctrl_handler); in imx355_set_ctrl()
1183 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_set_ctrl()
1191 max = imx355->cur_mode->height + ctrl->val - 10; in imx355_set_ctrl()
1192 __v4l2_ctrl_modify_range(imx355->exposure, in imx355_set_ctrl()
1193 imx355->exposure->minimum, in imx355_set_ctrl()
1194 max, imx355->exposure->step, max); in imx355_set_ctrl()
1208 ret = imx355_write_reg(imx355, IMX355_REG_ANALOG_GAIN, 2, in imx355_set_ctrl()
1212 ret = imx355_write_reg(imx355, IMX355_REG_DIG_GAIN_GLOBAL, 2, in imx355_set_ctrl()
1216 ret = imx355_write_reg(imx355, IMX355_REG_EXPOSURE, 2, in imx355_set_ctrl()
1221 ret = imx355_write_reg(imx355, IMX355_REG_FLL, 2, in imx355_set_ctrl()
1222 imx355->cur_mode->height + ctrl->val); in imx355_set_ctrl()
1225 ret = imx355_write_reg(imx355, IMX355_REG_TEST_PATTERN, in imx355_set_ctrl()
1230 ret = imx355_write_reg(imx355, IMX355_REG_ORIENTATION, 1, in imx355_set_ctrl()
1231 imx355->hflip->val | in imx355_set_ctrl()
1232 imx355->vflip->val << 1); in imx355_set_ctrl()
1254 struct imx355 *imx355 = to_imx355(sd); in imx355_enum_mbus_code() local
1259 mutex_lock(&imx355->mutex); in imx355_enum_mbus_code()
1260 code->code = imx355_get_format_code(imx355); in imx355_enum_mbus_code()
1261 mutex_unlock(&imx355->mutex); in imx355_enum_mbus_code()
1270 struct imx355 *imx355 = to_imx355(sd); in imx355_enum_frame_size() local
1275 mutex_lock(&imx355->mutex); in imx355_enum_frame_size()
1276 if (fse->code != imx355_get_format_code(imx355)) { in imx355_enum_frame_size()
1277 mutex_unlock(&imx355->mutex); in imx355_enum_frame_size()
1280 mutex_unlock(&imx355->mutex); in imx355_enum_frame_size()
1290 static void imx355_update_pad_format(struct imx355 *imx355, in imx355_update_pad_format() argument
1296 fmt->format.code = imx355_get_format_code(imx355); in imx355_update_pad_format()
1300 static int imx355_do_get_pad_format(struct imx355 *imx355, in imx355_do_get_pad_format() argument
1305 struct v4l2_subdev *sd = &imx355->sd; in imx355_do_get_pad_format()
1311 imx355_update_pad_format(imx355, imx355->cur_mode, fmt); in imx355_do_get_pad_format()
1321 struct imx355 *imx355 = to_imx355(sd); in imx355_get_pad_format() local
1324 mutex_lock(&imx355->mutex); in imx355_get_pad_format()
1325 ret = imx355_do_get_pad_format(imx355, sd_state, fmt); in imx355_get_pad_format()
1326 mutex_unlock(&imx355->mutex); in imx355_get_pad_format()
1336 struct imx355 *imx355 = to_imx355(sd); in imx355_set_pad_format() local
1345 mutex_lock(&imx355->mutex); in imx355_set_pad_format()
1351 fmt->format.code = imx355_get_format_code(imx355); in imx355_set_pad_format()
1357 imx355_update_pad_format(imx355, mode, fmt); in imx355_set_pad_format()
1362 imx355->cur_mode = mode; in imx355_set_pad_format()
1363 pixel_rate = imx355->link_def_freq * 2 * 4; in imx355_set_pad_format()
1365 __v4l2_ctrl_s_ctrl_int64(imx355->pixel_rate, pixel_rate); in imx355_set_pad_format()
1367 height = imx355->cur_mode->height; in imx355_set_pad_format()
1368 vblank_def = imx355->cur_mode->fll_def - height; in imx355_set_pad_format()
1369 vblank_min = imx355->cur_mode->fll_min - height; in imx355_set_pad_format()
1371 __v4l2_ctrl_modify_range(imx355->vblank, vblank_min, height, 1, in imx355_set_pad_format()
1373 __v4l2_ctrl_s_ctrl(imx355->vblank, vblank_def); in imx355_set_pad_format()
1374 h_blank = mode->llp - imx355->cur_mode->width; in imx355_set_pad_format()
1379 __v4l2_ctrl_modify_range(imx355->hblank, h_blank, in imx355_set_pad_format()
1383 mutex_unlock(&imx355->mutex); in imx355_set_pad_format()
1389 static int imx355_start_streaming(struct imx355 *imx355) in imx355_start_streaming() argument
1391 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_start_streaming()
1397 ret = imx355_write_regs(imx355, reg_list->regs, reg_list->num_of_regs); in imx355_start_streaming()
1404 reg_list = &imx355->cur_mode->reg_list; in imx355_start_streaming()
1405 ret = imx355_write_regs(imx355, reg_list->regs, reg_list->num_of_regs); in imx355_start_streaming()
1412 ret = imx355_write_reg(imx355, IMX355_REG_DPGA_USE_GLOBAL_GAIN, 1, 1); in imx355_start_streaming()
1417 ret = __v4l2_ctrl_handler_setup(imx355->sd.ctrl_handler); in imx355_start_streaming()
1421 return imx355_write_reg(imx355, IMX355_REG_MODE_SELECT, in imx355_start_streaming()
1426 static int imx355_stop_streaming(struct imx355 *imx355) in imx355_stop_streaming() argument
1428 return imx355_write_reg(imx355, IMX355_REG_MODE_SELECT, in imx355_stop_streaming()
1434 struct imx355 *imx355 = to_imx355(sd); in imx355_set_stream() local
1438 mutex_lock(&imx355->mutex); in imx355_set_stream()
1439 if (imx355->streaming == enable) { in imx355_set_stream()
1440 mutex_unlock(&imx355->mutex); in imx355_set_stream()
1453 ret = imx355_start_streaming(imx355); in imx355_set_stream()
1457 imx355_stop_streaming(imx355); in imx355_set_stream()
1461 imx355->streaming = enable; in imx355_set_stream()
1464 __v4l2_ctrl_grab(imx355->vflip, enable); in imx355_set_stream()
1465 __v4l2_ctrl_grab(imx355->hflip, enable); in imx355_set_stream()
1467 mutex_unlock(&imx355->mutex); in imx355_set_stream()
1474 mutex_unlock(&imx355->mutex); in imx355_set_stream()
1482 struct imx355 *imx355 = to_imx355(sd); in imx355_suspend() local
1484 if (imx355->streaming) in imx355_suspend()
1485 imx355_stop_streaming(imx355); in imx355_suspend()
1493 struct imx355 *imx355 = to_imx355(sd); in imx355_resume() local
1496 if (imx355->streaming) { in imx355_resume()
1497 ret = imx355_start_streaming(imx355); in imx355_resume()
1505 imx355_stop_streaming(imx355); in imx355_resume()
1506 imx355->streaming = 0; in imx355_resume()
1511 static int imx355_identify_module(struct imx355 *imx355) in imx355_identify_module() argument
1513 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_identify_module()
1517 ret = imx355_read_reg(imx355, IMX355_REG_CHIP_ID, 2, &val); in imx355_identify_module()
1560 static int imx355_init_controls(struct imx355 *imx355) in imx355_init_controls() argument
1562 struct i2c_client *client = v4l2_get_subdevdata(&imx355->sd); in imx355_init_controls()
1573 ctrl_hdlr = &imx355->ctrl_handler; in imx355_init_controls()
1578 ctrl_hdlr->lock = &imx355->mutex; in imx355_init_controls()
1580 imx355->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1583 if (imx355->link_freq) in imx355_init_controls()
1584 imx355->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; in imx355_init_controls()
1587 pixel_rate = imx355->link_def_freq * 2 * 4; in imx355_init_controls()
1590 imx355->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1595 mode = imx355->cur_mode; in imx355_init_controls()
1598 imx355->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1604 imx355->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1607 if (imx355->hblank) in imx355_init_controls()
1608 imx355->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; in imx355_init_controls()
1612 imx355->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1618 imx355->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1620 if (imx355->hflip) in imx355_init_controls()
1621 imx355->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT; in imx355_init_controls()
1622 imx355->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx355_ctrl_ops, in imx355_init_controls()
1624 if (imx355->vflip) in imx355_init_controls()
1625 imx355->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT; in imx355_init_controls()
1646 imx355->sd.ctrl_handler = ctrl_hdlr; in imx355_init_controls()
1726 struct imx355 *imx355; in imx355_probe() local
1730 imx355 = devm_kzalloc(&client->dev, sizeof(*imx355), GFP_KERNEL); in imx355_probe()
1731 if (!imx355) in imx355_probe()
1734 mutex_init(&imx355->mutex); in imx355_probe()
1737 v4l2_i2c_subdev_init(&imx355->sd, client, &imx355_subdev_ops); in imx355_probe()
1740 ret = imx355_identify_module(imx355); in imx355_probe()
1746 imx355->hwcfg = imx355_get_hwcfg(&client->dev); in imx355_probe()
1747 if (!imx355->hwcfg) { in imx355_probe()
1753 imx355->link_def_freq = link_freq_menu_items[IMX355_LINK_FREQ_INDEX]; in imx355_probe()
1754 for (i = 0; i < imx355->hwcfg->nr_of_link_freqs; i++) { in imx355_probe()
1755 if (imx355->hwcfg->link_freqs[i] == imx355->link_def_freq) { in imx355_probe()
1761 if (i == imx355->hwcfg->nr_of_link_freqs) { in imx355_probe()
1768 imx355->cur_mode = &supported_modes[0]; in imx355_probe()
1770 ret = imx355_init_controls(imx355); in imx355_probe()
1777 imx355->sd.internal_ops = &imx355_internal_ops; in imx355_probe()
1778 imx355->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | in imx355_probe()
1780 imx355->sd.entity.ops = &imx355_subdev_entity_ops; in imx355_probe()
1781 imx355->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; in imx355_probe()
1784 imx355->pad.flags = MEDIA_PAD_FL_SOURCE; in imx355_probe()
1785 ret = media_entity_pads_init(&imx355->sd.entity, 1, &imx355->pad); in imx355_probe()
1799 ret = v4l2_async_register_subdev_sensor(&imx355->sd); in imx355_probe()
1808 media_entity_cleanup(&imx355->sd.entity); in imx355_probe()
1811 v4l2_ctrl_handler_free(imx355->sd.ctrl_handler); in imx355_probe()
1814 mutex_destroy(&imx355->mutex); in imx355_probe()
1822 struct imx355 *imx355 = to_imx355(sd); in imx355_remove() local
1831 mutex_destroy(&imx355->mutex); in imx355_remove()