Lines Matching refs:csid

87 static int csid_set_clock_rates(struct csid_device *csid)  in csid_set_clock_rates()  argument
89 struct device *dev = csid->camss->dev; in csid_set_clock_rates()
95 fmt = csid_get_fmt_entry(csid->formats, csid->nformats, in csid_set_clock_rates()
96 csid->fmt[MSM_CSIPHY_PAD_SINK].code); in csid_set_clock_rates()
97 link_freq = camss_get_link_freq(&csid->subdev.entity, fmt->bpp, in csid_set_clock_rates()
98 csid->phy.lane_cnt); in csid_set_clock_rates()
102 for (i = 0; i < csid->nclocks; i++) { in csid_set_clock_rates()
103 struct camss_clock *clock = &csid->clock[i]; in csid_set_clock_rates()
158 struct csid_device *csid = v4l2_get_subdevdata(sd); in csid_set_power() local
159 struct camss *camss = csid->camss; in csid_set_power()
161 struct vfe_device *vfe = &camss->vfe[csid->id]; in csid_set_power()
176 ret = regulator_bulk_enable(csid->num_supplies, in csid_set_power()
177 csid->supplies); in csid_set_power()
183 ret = csid_set_clock_rates(csid); in csid_set_power()
185 regulator_bulk_disable(csid->num_supplies, in csid_set_power()
186 csid->supplies); in csid_set_power()
191 ret = camss_enable_clocks(csid->nclocks, csid->clock, dev); in csid_set_power()
193 regulator_bulk_disable(csid->num_supplies, in csid_set_power()
194 csid->supplies); in csid_set_power()
199 csid->phy.need_vc_update = true; in csid_set_power()
201 enable_irq(csid->irq); in csid_set_power()
203 ret = csid->ops->reset(csid); in csid_set_power()
205 disable_irq(csid->irq); in csid_set_power()
206 camss_disable_clocks(csid->nclocks, csid->clock); in csid_set_power()
207 regulator_bulk_disable(csid->num_supplies, in csid_set_power()
208 csid->supplies); in csid_set_power()
213 csid->ops->hw_version(csid); in csid_set_power()
215 disable_irq(csid->irq); in csid_set_power()
216 camss_disable_clocks(csid->nclocks, csid->clock); in csid_set_power()
217 regulator_bulk_disable(csid->num_supplies, in csid_set_power()
218 csid->supplies); in csid_set_power()
238 struct csid_device *csid = v4l2_get_subdevdata(sd); in csid_set_stream() local
242 ret = v4l2_ctrl_handler_setup(&csid->ctrls); in csid_set_stream()
244 dev_err(csid->camss->dev, in csid_set_stream()
249 if (!csid->testgen.enabled && in csid_set_stream()
250 !media_pad_remote_pad_first(&csid->pads[MSM_CSID_PAD_SINK])) in csid_set_stream()
254 if (csid->phy.need_vc_update) { in csid_set_stream()
255 csid->ops->configure_stream(csid, enable); in csid_set_stream()
256 csid->phy.need_vc_update = false; in csid_set_stream()
272 __csid_get_format(struct csid_device *csid, in __csid_get_format() argument
278 return v4l2_subdev_get_try_format(&csid->subdev, sd_state, in __csid_get_format()
281 return &csid->fmt[pad]; in __csid_get_format()
292 static void csid_try_format(struct csid_device *csid, in csid_try_format() argument
304 for (i = 0; i < csid->nformats; i++) in csid_try_format()
305 if (fmt->code == csid->formats[i].code) in csid_try_format()
309 if (i >= csid->nformats) in csid_try_format()
321 if (csid->testgen_mode->cur.val == 0) { in csid_try_format()
326 *fmt = *__csid_get_format(csid, sd_state, in csid_try_format()
328 fmt->code = csid->ops->src_pad_code(csid, fmt->code, 0, code); in csid_try_format()
333 for (i = 0; i < csid->nformats; i++) in csid_try_format()
334 if (csid->formats[i].code == fmt->code) in csid_try_format()
338 if (i >= csid->nformats) in csid_try_format()
363 struct csid_device *csid = v4l2_get_subdevdata(sd); in csid_enum_mbus_code() local
366 if (code->index >= csid->nformats) in csid_enum_mbus_code()
369 code->code = csid->formats[code->index].code; in csid_enum_mbus_code()
371 if (csid->testgen_mode->cur.val == 0) { in csid_enum_mbus_code()
374 sink_fmt = __csid_get_format(csid, sd_state, in csid_enum_mbus_code()
378 code->code = csid->ops->src_pad_code(csid, sink_fmt->code, in csid_enum_mbus_code()
383 if (code->index >= csid->nformats) in csid_enum_mbus_code()
386 code->code = csid->formats[code->index].code; in csid_enum_mbus_code()
404 struct csid_device *csid = v4l2_get_subdevdata(sd); in csid_enum_frame_size() local
413 csid_try_format(csid, sd_state, fse->pad, &format, fse->which); in csid_enum_frame_size()
423 csid_try_format(csid, sd_state, fse->pad, &format, fse->which); in csid_enum_frame_size()
442 struct csid_device *csid = v4l2_get_subdevdata(sd); in csid_get_format() local
445 format = __csid_get_format(csid, sd_state, fmt->pad, fmt->which); in csid_get_format()
466 struct csid_device *csid = v4l2_get_subdevdata(sd); in csid_set_format() local
470 format = __csid_get_format(csid, sd_state, fmt->pad, fmt->which); in csid_set_format()
474 csid_try_format(csid, sd_state, fmt->pad, &fmt->format, fmt->which); in csid_set_format()
480 format = __csid_get_format(csid, sd_state, i, fmt->which); in csid_set_format()
483 csid_try_format(csid, sd_state, i, format, fmt->which); in csid_set_format()
522 static int csid_set_test_pattern(struct csid_device *csid, s32 value) in csid_set_test_pattern() argument
524 struct csid_testgen_config *tg = &csid->testgen; in csid_set_test_pattern()
527 if (value && media_pad_remote_pad_first(&csid->pads[MSM_CSID_PAD_SINK])) in csid_set_test_pattern()
532 return csid->ops->configure_testgen_pattern(csid, value); in csid_set_test_pattern()
543 struct csid_device *csid = container_of(ctrl->handler, in csid_s_ctrl() local
549 ret = csid_set_test_pattern(csid, ctrl->val); in csid_s_ctrl()
568 int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid, in msm_csid_subdev_init() argument
576 csid->camss = camss; in msm_csid_subdev_init()
577 csid->id = id; in msm_csid_subdev_init()
580 csid->ops = &csid_ops_4_1; in msm_csid_subdev_init()
583 csid->ops = &csid_ops_4_7; in msm_csid_subdev_init()
586 csid->ops = &csid_ops_gen2; in msm_csid_subdev_init()
590 csid->ops->subdev_init(csid); in msm_csid_subdev_init()
600 csid->base = camss->vfe[id].base + VFE_480_LITE_CSID_OFFSET; in msm_csid_subdev_init()
602 csid->base = camss->vfe[id].base + VFE_480_CSID_OFFSET; in msm_csid_subdev_init()
604 csid->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]); in msm_csid_subdev_init()
605 if (IS_ERR(csid->base)) in msm_csid_subdev_init()
606 return PTR_ERR(csid->base); in msm_csid_subdev_init()
615 csid->irq = ret; in msm_csid_subdev_init()
616 snprintf(csid->irq_name, sizeof(csid->irq_name), "%s_%s%d", in msm_csid_subdev_init()
617 dev_name(dev), MSM_CSID_NAME, csid->id); in msm_csid_subdev_init()
618 ret = devm_request_irq(dev, csid->irq, csid->ops->isr, in msm_csid_subdev_init()
620 csid->irq_name, csid); in msm_csid_subdev_init()
628 csid->nclocks = 0; in msm_csid_subdev_init()
629 while (res->clock[csid->nclocks]) in msm_csid_subdev_init()
630 csid->nclocks++; in msm_csid_subdev_init()
632 csid->clock = devm_kcalloc(dev, csid->nclocks, sizeof(*csid->clock), in msm_csid_subdev_init()
634 if (!csid->clock) in msm_csid_subdev_init()
637 for (i = 0; i < csid->nclocks; i++) { in msm_csid_subdev_init()
638 struct camss_clock *clock = &csid->clock[i]; in msm_csid_subdev_init()
669 csid->num_supplies++; in msm_csid_subdev_init()
672 if (csid->num_supplies) { in msm_csid_subdev_init()
673 csid->supplies = devm_kmalloc_array(camss->dev, in msm_csid_subdev_init()
674 csid->num_supplies, in msm_csid_subdev_init()
675 sizeof(*csid->supplies), in msm_csid_subdev_init()
677 if (!csid->supplies) in msm_csid_subdev_init()
681 for (i = 0; i < csid->num_supplies; i++) in msm_csid_subdev_init()
682 csid->supplies[i].supply = res->regulators[i]; in msm_csid_subdev_init()
684 ret = devm_regulator_bulk_get(camss->dev, csid->num_supplies, in msm_csid_subdev_init()
685 csid->supplies); in msm_csid_subdev_init()
689 init_completion(&csid->reset_complete); in msm_csid_subdev_init()
702 struct csid_device *csid = v4l2_get_subdevdata(sd); in msm_csid_get_csid_id() local
704 *id = csid->id; in msm_csid_get_csid_id()
744 struct csid_device *csid; in csid_link_setup() local
749 csid = v4l2_get_subdevdata(sd); in csid_link_setup()
753 if (csid->testgen_mode->cur.val != 0) in csid_link_setup()
764 csid->phy.csiphy_id = csiphy->id; in csid_link_setup()
767 csid->phy.lane_cnt = lane_cfg->num_data; in csid_link_setup()
768 csid->phy.lane_assign = csid_get_lane_assign(lane_cfg); in csid_link_setup()
773 struct csid_device *csid = v4l2_get_subdevdata(sd); in csid_link_setup() local
774 struct device *dev = csid->camss->dev; in csid_link_setup()
777 csid->phy.en_vc |= BIT(local->index - 1); in csid_link_setup()
779 csid->phy.en_vc &= ~BIT(local->index - 1); in csid_link_setup()
781 csid->phy.need_vc_update = true; in csid_link_setup()
784 __func__, csid->phy.en_vc); in csid_link_setup()
829 int msm_csid_register_entity(struct csid_device *csid, in msm_csid_register_entity() argument
832 struct v4l2_subdev *sd = &csid->subdev; in msm_csid_register_entity()
833 struct media_pad *pads = csid->pads; in msm_csid_register_entity()
834 struct device *dev = csid->camss->dev; in msm_csid_register_entity()
843 MSM_CSID_NAME, csid->id); in msm_csid_register_entity()
844 v4l2_set_subdevdata(sd, csid); in msm_csid_register_entity()
846 ret = v4l2_ctrl_handler_init(&csid->ctrls, 1); in msm_csid_register_entity()
852 csid->testgen_mode = v4l2_ctrl_new_std_menu_items(&csid->ctrls, in msm_csid_register_entity()
854 csid->testgen.nmodes, 0, 0, in msm_csid_register_entity()
855 csid->testgen.modes); in msm_csid_register_entity()
857 if (csid->ctrls.error) { in msm_csid_register_entity()
858 dev_err(dev, "Failed to init ctrl: %d\n", csid->ctrls.error); in msm_csid_register_entity()
859 ret = csid->ctrls.error; in msm_csid_register_entity()
863 csid->subdev.ctrl_handler = &csid->ctrls; in msm_csid_register_entity()
894 v4l2_ctrl_handler_free(&csid->ctrls); in msm_csid_register_entity()
903 void msm_csid_unregister_entity(struct csid_device *csid) in msm_csid_unregister_entity() argument
905 v4l2_device_unregister_subdev(&csid->subdev); in msm_csid_unregister_entity()
906 media_entity_cleanup(&csid->subdev.entity); in msm_csid_unregister_entity()
907 v4l2_ctrl_handler_free(&csid->ctrls); in msm_csid_unregister_entity()