imx214 426 drivers/media/i2c/imx214.c static inline struct imx214 *to_imx214(struct v4l2_subdev *sd) imx214 428 drivers/media/i2c/imx214.c return container_of(sd, struct imx214, sd); imx214 435 drivers/media/i2c/imx214.c struct imx214 *imx214 = to_imx214(sd); imx214 438 drivers/media/i2c/imx214.c ret = regulator_bulk_enable(IMX214_NUM_SUPPLIES, imx214->supplies); imx214 440 drivers/media/i2c/imx214.c dev_err(imx214->dev, "failed to enable regulators: %d\n", ret); imx214 446 drivers/media/i2c/imx214.c ret = clk_prepare_enable(imx214->xclk); imx214 448 drivers/media/i2c/imx214.c regulator_bulk_disable(IMX214_NUM_SUPPLIES, imx214->supplies); imx214 449 drivers/media/i2c/imx214.c dev_err(imx214->dev, "clk prepare enable failed\n"); imx214 453 drivers/media/i2c/imx214.c gpiod_set_value_cansleep(imx214->enable_gpio, 1); imx214 463 drivers/media/i2c/imx214.c struct imx214 *imx214 = to_imx214(sd); imx214 465 drivers/media/i2c/imx214.c gpiod_set_value_cansleep(imx214->enable_gpio, 0); imx214 467 drivers/media/i2c/imx214.c clk_disable_unprepare(imx214->xclk); imx214 469 drivers/media/i2c/imx214.c regulator_bulk_disable(IMX214_NUM_SUPPLIES, imx214->supplies); imx214 507 drivers/media/i2c/imx214.c struct imx214 *imx214 = container_of(subdev, struct imx214, sd); imx214 509 drivers/media/i2c/imx214.c return regmap_write(imx214->regmap, reg->reg, reg->val); imx214 515 drivers/media/i2c/imx214.c struct imx214 *imx214 = container_of(subdev, struct imx214, sd); imx214 520 drivers/media/i2c/imx214.c ret = regmap_read(imx214->regmap, reg->reg, &aux); imx214 535 drivers/media/i2c/imx214.c __imx214_get_pad_format(struct imx214 *imx214, imx214 542 drivers/media/i2c/imx214.c return v4l2_subdev_get_try_format(&imx214->sd, cfg, pad); imx214 544 drivers/media/i2c/imx214.c return &imx214->fmt; imx214 554 drivers/media/i2c/imx214.c struct imx214 *imx214 = to_imx214(sd); imx214 556 drivers/media/i2c/imx214.c mutex_lock(&imx214->mutex); imx214 557 drivers/media/i2c/imx214.c format->format = *__imx214_get_pad_format(imx214, cfg, format->pad, imx214 559 drivers/media/i2c/imx214.c mutex_unlock(&imx214->mutex); imx214 565 drivers/media/i2c/imx214.c __imx214_get_pad_crop(struct imx214 *imx214, struct v4l2_subdev_pad_config *cfg, imx214 570 drivers/media/i2c/imx214.c return v4l2_subdev_get_try_crop(&imx214->sd, cfg, pad); imx214 572 drivers/media/i2c/imx214.c return &imx214->crop; imx214 582 drivers/media/i2c/imx214.c struct imx214 *imx214 = to_imx214(sd); imx214 587 drivers/media/i2c/imx214.c mutex_lock(&imx214->mutex); imx214 589 drivers/media/i2c/imx214.c __crop = __imx214_get_pad_crop(imx214, cfg, format->pad, format->which); imx214 599 drivers/media/i2c/imx214.c __format = __imx214_get_pad_format(imx214, cfg, format->pad, imx214 613 drivers/media/i2c/imx214.c mutex_unlock(&imx214->mutex); imx214 622 drivers/media/i2c/imx214.c struct imx214 *imx214 = to_imx214(sd); imx214 627 drivers/media/i2c/imx214.c mutex_lock(&imx214->mutex); imx214 628 drivers/media/i2c/imx214.c sel->r = *__imx214_get_pad_crop(imx214, cfg, sel->pad, imx214 630 drivers/media/i2c/imx214.c mutex_unlock(&imx214->mutex); imx214 650 drivers/media/i2c/imx214.c struct imx214 *imx214 = container_of(ctrl->handler, imx214 651 drivers/media/i2c/imx214.c struct imx214, ctrls); imx214 659 drivers/media/i2c/imx214.c if (!pm_runtime_get_if_in_use(imx214->dev)) imx214 666 drivers/media/i2c/imx214.c ret = regmap_bulk_write(imx214->regmap, 0x202, vals, 2); imx214 668 drivers/media/i2c/imx214.c dev_err(imx214->dev, "Error %d\n", ret); imx214 676 drivers/media/i2c/imx214.c pm_runtime_put(imx214->dev); imx214 686 drivers/media/i2c/imx214.c static int imx214_write_table(struct imx214 *imx214, imx214 706 drivers/media/i2c/imx214.c ret = regmap_bulk_write(imx214->regmap, table->addr, vals, i); imx214 709 drivers/media/i2c/imx214.c dev_err(imx214->dev, "write_table error: %d\n", ret); imx214 719 drivers/media/i2c/imx214.c static int imx214_start_streaming(struct imx214 *imx214) imx214 724 drivers/media/i2c/imx214.c mutex_lock(&imx214->mutex); imx214 725 drivers/media/i2c/imx214.c ret = imx214_write_table(imx214, mode_table_common); imx214 727 drivers/media/i2c/imx214.c dev_err(imx214->dev, "could not sent common table %d\n", ret); imx214 733 drivers/media/i2c/imx214.c imx214->fmt.width, imx214->fmt.height); imx214 734 drivers/media/i2c/imx214.c ret = imx214_write_table(imx214, mode->reg_table); imx214 736 drivers/media/i2c/imx214.c dev_err(imx214->dev, "could not sent mode table %d\n", ret); imx214 739 drivers/media/i2c/imx214.c ret = __v4l2_ctrl_handler_setup(&imx214->ctrls); imx214 741 drivers/media/i2c/imx214.c dev_err(imx214->dev, "could not sync v4l2 controls\n"); imx214 744 drivers/media/i2c/imx214.c ret = regmap_write(imx214->regmap, 0x100, 1); imx214 746 drivers/media/i2c/imx214.c dev_err(imx214->dev, "could not sent start table %d\n", ret); imx214 750 drivers/media/i2c/imx214.c mutex_unlock(&imx214->mutex); imx214 754 drivers/media/i2c/imx214.c mutex_unlock(&imx214->mutex); imx214 758 drivers/media/i2c/imx214.c static int imx214_stop_streaming(struct imx214 *imx214) imx214 762 drivers/media/i2c/imx214.c ret = regmap_write(imx214->regmap, 0x100, 0); imx214 764 drivers/media/i2c/imx214.c dev_err(imx214->dev, "could not sent stop table %d\n", ret); imx214 771 drivers/media/i2c/imx214.c struct imx214 *imx214 = to_imx214(subdev); imx214 774 drivers/media/i2c/imx214.c if (imx214->streaming == enable) imx214 778 drivers/media/i2c/imx214.c ret = pm_runtime_get_sync(imx214->dev); imx214 780 drivers/media/i2c/imx214.c pm_runtime_put_noidle(imx214->dev); imx214 784 drivers/media/i2c/imx214.c ret = imx214_start_streaming(imx214); imx214 788 drivers/media/i2c/imx214.c ret = imx214_start_streaming(imx214); imx214 791 drivers/media/i2c/imx214.c pm_runtime_put(imx214->dev); imx214 794 drivers/media/i2c/imx214.c imx214->streaming = enable; imx214 798 drivers/media/i2c/imx214.c pm_runtime_put(imx214->dev); imx214 862 drivers/media/i2c/imx214.c static int imx214_get_regulators(struct device *dev, struct imx214 *imx214) imx214 867 drivers/media/i2c/imx214.c imx214->supplies[i].supply = imx214_supply_name[i]; imx214 870 drivers/media/i2c/imx214.c imx214->supplies); imx214 915 drivers/media/i2c/imx214.c struct imx214 *imx214 = to_imx214(sd); imx214 917 drivers/media/i2c/imx214.c if (imx214->streaming) imx214 918 drivers/media/i2c/imx214.c imx214_stop_streaming(imx214); imx214 927 drivers/media/i2c/imx214.c struct imx214 *imx214 = to_imx214(sd); imx214 930 drivers/media/i2c/imx214.c if (imx214->streaming) { imx214 931 drivers/media/i2c/imx214.c ret = imx214_start_streaming(imx214); imx214 939 drivers/media/i2c/imx214.c imx214_stop_streaming(imx214); imx214 940 drivers/media/i2c/imx214.c imx214->streaming = 0; imx214 947 drivers/media/i2c/imx214.c struct imx214 *imx214; imx214 957 drivers/media/i2c/imx214.c imx214 = devm_kzalloc(dev, sizeof(*imx214), GFP_KERNEL); imx214 958 drivers/media/i2c/imx214.c if (!imx214) imx214 961 drivers/media/i2c/imx214.c imx214->dev = dev; imx214 963 drivers/media/i2c/imx214.c imx214->xclk = devm_clk_get(dev, NULL); imx214 964 drivers/media/i2c/imx214.c if (IS_ERR(imx214->xclk)) { imx214 966 drivers/media/i2c/imx214.c return PTR_ERR(imx214->xclk); imx214 969 drivers/media/i2c/imx214.c ret = clk_set_rate(imx214->xclk, IMX214_DEFAULT_CLK_FREQ); imx214 975 drivers/media/i2c/imx214.c ret = imx214_get_regulators(dev, imx214); imx214 981 drivers/media/i2c/imx214.c imx214->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); imx214 982 drivers/media/i2c/imx214.c if (IS_ERR(imx214->enable_gpio)) { imx214 984 drivers/media/i2c/imx214.c return PTR_ERR(imx214->enable_gpio); imx214 987 drivers/media/i2c/imx214.c imx214->regmap = devm_regmap_init_i2c(client, &sensor_regmap_config); imx214 988 drivers/media/i2c/imx214.c if (IS_ERR(imx214->regmap)) { imx214 990 drivers/media/i2c/imx214.c return PTR_ERR(imx214->regmap); imx214 993 drivers/media/i2c/imx214.c v4l2_i2c_subdev_init(&imx214->sd, client, &imx214_subdev_ops); imx214 999 drivers/media/i2c/imx214.c imx214_power_on(imx214->dev); imx214 1001 drivers/media/i2c/imx214.c pm_runtime_set_active(imx214->dev); imx214 1002 drivers/media/i2c/imx214.c pm_runtime_enable(imx214->dev); imx214 1003 drivers/media/i2c/imx214.c pm_runtime_idle(imx214->dev); imx214 1005 drivers/media/i2c/imx214.c v4l2_ctrl_handler_init(&imx214->ctrls, 3); imx214 1007 drivers/media/i2c/imx214.c imx214->pixel_rate = v4l2_ctrl_new_std(&imx214->ctrls, NULL, imx214 1011 drivers/media/i2c/imx214.c imx214->link_freq = v4l2_ctrl_new_int_menu(&imx214->ctrls, NULL, imx214 1015 drivers/media/i2c/imx214.c if (imx214->link_freq) imx214 1016 drivers/media/i2c/imx214.c imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; imx214 1028 drivers/media/i2c/imx214.c imx214->exposure = v4l2_ctrl_new_std(&imx214->ctrls, &imx214_ctrl_ops, imx214 1032 drivers/media/i2c/imx214.c ret = imx214->ctrls.error; imx214 1039 drivers/media/i2c/imx214.c imx214->sd.ctrl_handler = &imx214->ctrls; imx214 1040 drivers/media/i2c/imx214.c mutex_init(&imx214->mutex); imx214 1041 drivers/media/i2c/imx214.c imx214->ctrls.lock = &imx214->mutex; imx214 1043 drivers/media/i2c/imx214.c imx214->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; imx214 1044 drivers/media/i2c/imx214.c imx214->pad.flags = MEDIA_PAD_FL_SOURCE; imx214 1045 drivers/media/i2c/imx214.c imx214->sd.dev = &client->dev; imx214 1046 drivers/media/i2c/imx214.c imx214->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; imx214 1048 drivers/media/i2c/imx214.c ret = media_entity_pads_init(&imx214->sd.entity, 1, &imx214->pad); imx214 1054 drivers/media/i2c/imx214.c imx214_entity_init_cfg(&imx214->sd, NULL); imx214 1056 drivers/media/i2c/imx214.c ret = v4l2_async_register_subdev_sensor_common(&imx214->sd); imx214 1065 drivers/media/i2c/imx214.c media_entity_cleanup(&imx214->sd.entity); imx214 1067 drivers/media/i2c/imx214.c mutex_destroy(&imx214->mutex); imx214 1068 drivers/media/i2c/imx214.c v4l2_ctrl_handler_free(&imx214->ctrls); imx214 1069 drivers/media/i2c/imx214.c pm_runtime_disable(imx214->dev); imx214 1077 drivers/media/i2c/imx214.c struct imx214 *imx214 = to_imx214(sd); imx214 1079 drivers/media/i2c/imx214.c v4l2_async_unregister_subdev(&imx214->sd); imx214 1080 drivers/media/i2c/imx214.c media_entity_cleanup(&imx214->sd.entity); imx214 1081 drivers/media/i2c/imx214.c v4l2_ctrl_handler_free(&imx214->ctrls); imx214 1086 drivers/media/i2c/imx214.c mutex_destroy(&imx214->mutex);