imx319 1762 drivers/media/i2c/imx319.c static inline struct imx319 *to_imx319(struct v4l2_subdev *_sd) imx319 1764 drivers/media/i2c/imx319.c return container_of(_sd, struct imx319, sd); imx319 1768 drivers/media/i2c/imx319.c static u32 imx319_get_format_code(struct imx319 *imx319) imx319 1780 drivers/media/i2c/imx319.c lockdep_assert_held(&imx319->mutex); imx319 1781 drivers/media/i2c/imx319.c code = codes[imx319->vflip->val][imx319->hflip->val]; imx319 1787 drivers/media/i2c/imx319.c static int imx319_read_reg(struct imx319 *imx319, u16 reg, u32 len, u32 *val) imx319 1789 drivers/media/i2c/imx319.c struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); imx319 1821 drivers/media/i2c/imx319.c static int imx319_write_reg(struct imx319 *imx319, u16 reg, u32 len, u32 val) imx319 1823 drivers/media/i2c/imx319.c struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); imx319 1838 drivers/media/i2c/imx319.c static int imx319_write_regs(struct imx319 *imx319, imx319 1841 drivers/media/i2c/imx319.c struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); imx319 1846 drivers/media/i2c/imx319.c ret = imx319_write_reg(imx319, regs[i].address, 1, regs[i].val); imx319 1861 drivers/media/i2c/imx319.c struct imx319 *imx319 = to_imx319(sd); imx319 1865 drivers/media/i2c/imx319.c mutex_lock(&imx319->mutex); imx319 1868 drivers/media/i2c/imx319.c try_fmt->width = imx319->cur_mode->width; imx319 1869 drivers/media/i2c/imx319.c try_fmt->height = imx319->cur_mode->height; imx319 1870 drivers/media/i2c/imx319.c try_fmt->code = imx319_get_format_code(imx319); imx319 1873 drivers/media/i2c/imx319.c mutex_unlock(&imx319->mutex); imx319 1880 drivers/media/i2c/imx319.c struct imx319 *imx319 = container_of(ctrl->handler, imx319 1881 drivers/media/i2c/imx319.c struct imx319, ctrl_handler); imx319 1882 drivers/media/i2c/imx319.c struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); imx319 1890 drivers/media/i2c/imx319.c max = imx319->cur_mode->height + ctrl->val - 18; imx319 1891 drivers/media/i2c/imx319.c __v4l2_ctrl_modify_range(imx319->exposure, imx319 1892 drivers/media/i2c/imx319.c imx319->exposure->minimum, imx319 1893 drivers/media/i2c/imx319.c max, imx319->exposure->step, max); imx319 1907 drivers/media/i2c/imx319.c ret = imx319_write_reg(imx319, IMX319_REG_ANALOG_GAIN, 2, imx319 1911 drivers/media/i2c/imx319.c ret = imx319_write_reg(imx319, IMX319_REG_DIG_GAIN_GLOBAL, 2, imx319 1915 drivers/media/i2c/imx319.c ret = imx319_write_reg(imx319, IMX319_REG_EXPOSURE, 2, imx319 1920 drivers/media/i2c/imx319.c ret = imx319_write_reg(imx319, IMX319_REG_FLL, 2, imx319 1921 drivers/media/i2c/imx319.c imx319->cur_mode->height + ctrl->val); imx319 1924 drivers/media/i2c/imx319.c ret = imx319_write_reg(imx319, IMX319_REG_TEST_PATTERN, imx319 1929 drivers/media/i2c/imx319.c ret = imx319_write_reg(imx319, IMX319_REG_ORIENTATION, 1, imx319 1930 drivers/media/i2c/imx319.c imx319->hflip->val | imx319 1931 drivers/media/i2c/imx319.c imx319->vflip->val << 1); imx319 1953 drivers/media/i2c/imx319.c struct imx319 *imx319 = to_imx319(sd); imx319 1958 drivers/media/i2c/imx319.c mutex_lock(&imx319->mutex); imx319 1959 drivers/media/i2c/imx319.c code->code = imx319_get_format_code(imx319); imx319 1960 drivers/media/i2c/imx319.c mutex_unlock(&imx319->mutex); imx319 1969 drivers/media/i2c/imx319.c struct imx319 *imx319 = to_imx319(sd); imx319 1974 drivers/media/i2c/imx319.c mutex_lock(&imx319->mutex); imx319 1975 drivers/media/i2c/imx319.c if (fse->code != imx319_get_format_code(imx319)) { imx319 1976 drivers/media/i2c/imx319.c mutex_unlock(&imx319->mutex); imx319 1979 drivers/media/i2c/imx319.c mutex_unlock(&imx319->mutex); imx319 1989 drivers/media/i2c/imx319.c static void imx319_update_pad_format(struct imx319 *imx319, imx319 1995 drivers/media/i2c/imx319.c fmt->format.code = imx319_get_format_code(imx319); imx319 1999 drivers/media/i2c/imx319.c static int imx319_do_get_pad_format(struct imx319 *imx319, imx319 2004 drivers/media/i2c/imx319.c struct v4l2_subdev *sd = &imx319->sd; imx319 2010 drivers/media/i2c/imx319.c imx319_update_pad_format(imx319, imx319->cur_mode, fmt); imx319 2020 drivers/media/i2c/imx319.c struct imx319 *imx319 = to_imx319(sd); imx319 2023 drivers/media/i2c/imx319.c mutex_lock(&imx319->mutex); imx319 2024 drivers/media/i2c/imx319.c ret = imx319_do_get_pad_format(imx319, cfg, fmt); imx319 2025 drivers/media/i2c/imx319.c mutex_unlock(&imx319->mutex); imx319 2035 drivers/media/i2c/imx319.c struct imx319 *imx319 = to_imx319(sd); imx319 2044 drivers/media/i2c/imx319.c mutex_lock(&imx319->mutex); imx319 2050 drivers/media/i2c/imx319.c fmt->format.code = imx319_get_format_code(imx319); imx319 2056 drivers/media/i2c/imx319.c imx319_update_pad_format(imx319, mode, fmt); imx319 2061 drivers/media/i2c/imx319.c imx319->cur_mode = mode; imx319 2062 drivers/media/i2c/imx319.c pixel_rate = imx319->link_def_freq * 2 * 4; imx319 2064 drivers/media/i2c/imx319.c __v4l2_ctrl_s_ctrl_int64(imx319->pixel_rate, pixel_rate); imx319 2066 drivers/media/i2c/imx319.c height = imx319->cur_mode->height; imx319 2067 drivers/media/i2c/imx319.c vblank_def = imx319->cur_mode->fll_def - height; imx319 2068 drivers/media/i2c/imx319.c vblank_min = imx319->cur_mode->fll_min - height; imx319 2070 drivers/media/i2c/imx319.c __v4l2_ctrl_modify_range(imx319->vblank, vblank_min, height, 1, imx319 2072 drivers/media/i2c/imx319.c __v4l2_ctrl_s_ctrl(imx319->vblank, vblank_def); imx319 2073 drivers/media/i2c/imx319.c h_blank = mode->llp - imx319->cur_mode->width; imx319 2078 drivers/media/i2c/imx319.c __v4l2_ctrl_modify_range(imx319->hblank, h_blank, imx319 2082 drivers/media/i2c/imx319.c mutex_unlock(&imx319->mutex); imx319 2088 drivers/media/i2c/imx319.c static int imx319_start_streaming(struct imx319 *imx319) imx319 2090 drivers/media/i2c/imx319.c struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); imx319 2096 drivers/media/i2c/imx319.c ret = imx319_write_regs(imx319, reg_list->regs, reg_list->num_of_regs); imx319 2103 drivers/media/i2c/imx319.c reg_list = &imx319->cur_mode->reg_list; imx319 2104 drivers/media/i2c/imx319.c ret = imx319_write_regs(imx319, reg_list->regs, reg_list->num_of_regs); imx319 2111 drivers/media/i2c/imx319.c ret = imx319_write_reg(imx319, IMX319_REG_DPGA_USE_GLOBAL_GAIN, 1, 1); imx319 2116 drivers/media/i2c/imx319.c ret = __v4l2_ctrl_handler_setup(imx319->sd.ctrl_handler); imx319 2120 drivers/media/i2c/imx319.c return imx319_write_reg(imx319, IMX319_REG_MODE_SELECT, imx319 2125 drivers/media/i2c/imx319.c static int imx319_stop_streaming(struct imx319 *imx319) imx319 2127 drivers/media/i2c/imx319.c return imx319_write_reg(imx319, IMX319_REG_MODE_SELECT, imx319 2133 drivers/media/i2c/imx319.c struct imx319 *imx319 = to_imx319(sd); imx319 2137 drivers/media/i2c/imx319.c mutex_lock(&imx319->mutex); imx319 2138 drivers/media/i2c/imx319.c if (imx319->streaming == enable) { imx319 2139 drivers/media/i2c/imx319.c mutex_unlock(&imx319->mutex); imx319 2154 drivers/media/i2c/imx319.c ret = imx319_start_streaming(imx319); imx319 2158 drivers/media/i2c/imx319.c imx319_stop_streaming(imx319); imx319 2162 drivers/media/i2c/imx319.c imx319->streaming = enable; imx319 2165 drivers/media/i2c/imx319.c __v4l2_ctrl_grab(imx319->vflip, enable); imx319 2166 drivers/media/i2c/imx319.c __v4l2_ctrl_grab(imx319->hflip, enable); imx319 2168 drivers/media/i2c/imx319.c mutex_unlock(&imx319->mutex); imx319 2175 drivers/media/i2c/imx319.c mutex_unlock(&imx319->mutex); imx319 2184 drivers/media/i2c/imx319.c struct imx319 *imx319 = to_imx319(sd); imx319 2186 drivers/media/i2c/imx319.c if (imx319->streaming) imx319 2187 drivers/media/i2c/imx319.c imx319_stop_streaming(imx319); imx319 2196 drivers/media/i2c/imx319.c struct imx319 *imx319 = to_imx319(sd); imx319 2199 drivers/media/i2c/imx319.c if (imx319->streaming) { imx319 2200 drivers/media/i2c/imx319.c ret = imx319_start_streaming(imx319); imx319 2208 drivers/media/i2c/imx319.c imx319_stop_streaming(imx319); imx319 2209 drivers/media/i2c/imx319.c imx319->streaming = 0; imx319 2214 drivers/media/i2c/imx319.c static int imx319_identify_module(struct imx319 *imx319) imx319 2216 drivers/media/i2c/imx319.c struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); imx319 2220 drivers/media/i2c/imx319.c ret = imx319_read_reg(imx319, IMX319_REG_CHIP_ID, 2, &val); imx319 2264 drivers/media/i2c/imx319.c static int imx319_init_controls(struct imx319 *imx319) imx319 2266 drivers/media/i2c/imx319.c struct i2c_client *client = v4l2_get_subdevdata(&imx319->sd); imx319 2277 drivers/media/i2c/imx319.c ctrl_hdlr = &imx319->ctrl_handler; imx319 2282 drivers/media/i2c/imx319.c ctrl_hdlr->lock = &imx319->mutex; imx319 2284 drivers/media/i2c/imx319.c imx319->link_freq = v4l2_ctrl_new_int_menu(ctrl_hdlr, &imx319_ctrl_ops, imx319 2287 drivers/media/i2c/imx319.c if (imx319->link_freq) imx319 2288 drivers/media/i2c/imx319.c imx319->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; imx319 2291 drivers/media/i2c/imx319.c pixel_rate = imx319->link_def_freq * 2 * 4; imx319 2294 drivers/media/i2c/imx319.c imx319->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops, imx319 2299 drivers/media/i2c/imx319.c mode = imx319->cur_mode; imx319 2302 drivers/media/i2c/imx319.c imx319->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops, imx319 2308 drivers/media/i2c/imx319.c imx319->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops, imx319 2311 drivers/media/i2c/imx319.c if (imx319->hblank) imx319 2312 drivers/media/i2c/imx319.c imx319->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; imx319 2316 drivers/media/i2c/imx319.c imx319->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops, imx319 2322 drivers/media/i2c/imx319.c imx319->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops, imx319 2324 drivers/media/i2c/imx319.c imx319->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx319_ctrl_ops, imx319 2346 drivers/media/i2c/imx319.c imx319->sd.ctrl_handler = ctrl_hdlr; imx319 2426 drivers/media/i2c/imx319.c struct imx319 *imx319; imx319 2430 drivers/media/i2c/imx319.c imx319 = devm_kzalloc(&client->dev, sizeof(*imx319), GFP_KERNEL); imx319 2431 drivers/media/i2c/imx319.c if (!imx319) imx319 2434 drivers/media/i2c/imx319.c mutex_init(&imx319->mutex); imx319 2437 drivers/media/i2c/imx319.c v4l2_i2c_subdev_init(&imx319->sd, client, &imx319_subdev_ops); imx319 2440 drivers/media/i2c/imx319.c ret = imx319_identify_module(imx319); imx319 2446 drivers/media/i2c/imx319.c imx319->hwcfg = imx319_get_hwcfg(&client->dev); imx319 2447 drivers/media/i2c/imx319.c if (!imx319->hwcfg) { imx319 2453 drivers/media/i2c/imx319.c imx319->link_def_freq = link_freq_menu_items[IMX319_LINK_FREQ_INDEX]; imx319 2454 drivers/media/i2c/imx319.c for (i = 0; i < imx319->hwcfg->nr_of_link_freqs; i++) { imx319 2455 drivers/media/i2c/imx319.c if (imx319->hwcfg->link_freqs[i] == imx319->link_def_freq) { imx319 2461 drivers/media/i2c/imx319.c if (i == imx319->hwcfg->nr_of_link_freqs) { imx319 2468 drivers/media/i2c/imx319.c imx319->cur_mode = &supported_modes[0]; imx319 2470 drivers/media/i2c/imx319.c ret = imx319_init_controls(imx319); imx319 2477 drivers/media/i2c/imx319.c imx319->sd.internal_ops = &imx319_internal_ops; imx319 2478 drivers/media/i2c/imx319.c imx319->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | imx319 2480 drivers/media/i2c/imx319.c imx319->sd.entity.ops = &imx319_subdev_entity_ops; imx319 2481 drivers/media/i2c/imx319.c imx319->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; imx319 2484 drivers/media/i2c/imx319.c imx319->pad.flags = MEDIA_PAD_FL_SOURCE; imx319 2485 drivers/media/i2c/imx319.c ret = media_entity_pads_init(&imx319->sd.entity, 1, &imx319->pad); imx319 2491 drivers/media/i2c/imx319.c ret = v4l2_async_register_subdev_sensor_common(&imx319->sd); imx319 2506 drivers/media/i2c/imx319.c media_entity_cleanup(&imx319->sd.entity); imx319 2509 drivers/media/i2c/imx319.c v4l2_ctrl_handler_free(imx319->sd.ctrl_handler); imx319 2512 drivers/media/i2c/imx319.c mutex_destroy(&imx319->mutex); imx319 2520 drivers/media/i2c/imx319.c struct imx319 *imx319 = to_imx319(sd); imx319 2529 drivers/media/i2c/imx319.c mutex_destroy(&imx319->mutex);