Lines Matching refs:vpbe_dev
59 vpbe_current_encoder_info(struct vpbe_device *vpbe_dev) in vpbe_current_encoder_info() argument
61 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_current_encoder_info()
62 int index = vpbe_dev->current_sd_index; in vpbe_current_encoder_info()
103 static int vpbe_g_cropcap(struct vpbe_device *vpbe_dev, in vpbe_g_cropcap() argument
110 cropcap->bounds.width = vpbe_dev->current_timings.xres; in vpbe_g_cropcap()
111 cropcap->bounds.height = vpbe_dev->current_timings.yres; in vpbe_g_cropcap()
125 static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev, in vpbe_enum_outputs() argument
128 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_enum_outputs()
140 static int vpbe_get_mode_info(struct vpbe_device *vpbe_dev, char *mode, in vpbe_get_mode_info() argument
143 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_get_mode_info()
154 vpbe_dev->current_timings = var; in vpbe_get_mode_info()
162 static int vpbe_get_current_mode_info(struct vpbe_device *vpbe_dev, in vpbe_get_current_mode_info() argument
168 *mode_info = vpbe_dev->current_timings; in vpbe_get_current_mode_info()
174 static int vpbe_get_std_info(struct vpbe_device *vpbe_dev, in vpbe_get_std_info() argument
177 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_get_std_info()
179 int curr_output = vpbe_dev->current_out_index; in vpbe_get_std_info()
182 for (i = 0; i < vpbe_dev->cfg->outputs[curr_output].num_modes; i++) { in vpbe_get_std_info()
186 vpbe_dev->current_timings = var; in vpbe_get_std_info()
194 static int vpbe_get_std_info_by_name(struct vpbe_device *vpbe_dev, in vpbe_get_std_info_by_name() argument
197 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_get_std_info_by_name()
199 int curr_output = vpbe_dev->current_out_index; in vpbe_get_std_info_by_name()
202 for (i = 0; i < vpbe_dev->cfg->outputs[curr_output].num_modes; i++) { in vpbe_get_std_info_by_name()
205 vpbe_dev->current_timings = var; in vpbe_get_std_info_by_name()
220 static int vpbe_set_output(struct vpbe_device *vpbe_dev, int index) in vpbe_set_output() argument
223 vpbe_current_encoder_info(vpbe_dev); in vpbe_set_output()
224 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_set_output()
225 struct venc_platform_data *venc_device = vpbe_dev->venc_device; in vpbe_set_output()
233 mutex_lock(&vpbe_dev->lock); in vpbe_set_output()
235 sd_index = vpbe_dev->current_sd_index; in vpbe_set_output()
261 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, in vpbe_set_output()
274 ret = vpbe_get_mode_info(vpbe_dev, in vpbe_set_output()
277 struct osd_state *osd_device = vpbe_dev->osd_device; in vpbe_set_output()
280 vpbe_dev->current_timings.left_margin); in vpbe_set_output()
282 vpbe_dev->current_timings.upper_margin); in vpbe_set_output()
283 vpbe_dev->current_sd_index = sd_index; in vpbe_set_output()
284 vpbe_dev->current_out_index = index; in vpbe_set_output()
287 mutex_unlock(&vpbe_dev->lock); in vpbe_set_output()
291 static int vpbe_set_default_output(struct vpbe_device *vpbe_dev) in vpbe_set_default_output() argument
293 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_set_default_output()
299 int ret = vpbe_set_output(vpbe_dev, i); in vpbe_set_default_output()
302 vpbe_dev->current_out_index = i; in vpbe_set_default_output()
315 static unsigned int vpbe_get_output(struct vpbe_device *vpbe_dev) in vpbe_get_output() argument
317 return vpbe_dev->current_out_index; in vpbe_get_output()
326 static int vpbe_s_dv_timings(struct vpbe_device *vpbe_dev, in vpbe_s_dv_timings() argument
329 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_s_dv_timings()
330 int out_index = vpbe_dev->current_out_index; in vpbe_s_dv_timings()
332 int sd_index = vpbe_dev->current_sd_index; in vpbe_s_dv_timings()
348 vpbe_dev->current_timings = output->modes[i]; in vpbe_s_dv_timings()
349 mutex_lock(&vpbe_dev->lock); in vpbe_s_dv_timings()
351 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, in vpbe_s_dv_timings()
353 if (!ret && vpbe_dev->amp) { in vpbe_s_dv_timings()
355 ret = v4l2_subdev_call(vpbe_dev->amp, video, in vpbe_s_dv_timings()
360 struct osd_state *osd_device = vpbe_dev->osd_device; in vpbe_s_dv_timings()
363 vpbe_dev->current_timings.left_margin); in vpbe_s_dv_timings()
365 vpbe_dev->current_timings.upper_margin); in vpbe_s_dv_timings()
367 mutex_unlock(&vpbe_dev->lock); in vpbe_s_dv_timings()
378 static int vpbe_g_dv_timings(struct vpbe_device *vpbe_dev, in vpbe_g_dv_timings() argument
381 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_g_dv_timings()
382 int out_index = vpbe_dev->current_out_index; in vpbe_g_dv_timings()
388 if (vpbe_dev->current_timings.timings_type & in vpbe_g_dv_timings()
390 *dv_timings = vpbe_dev->current_timings.dv_timings; in vpbe_g_dv_timings()
403 static int vpbe_enum_dv_timings(struct vpbe_device *vpbe_dev, in vpbe_enum_dv_timings() argument
406 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_enum_dv_timings()
407 int out_index = vpbe_dev->current_out_index; in vpbe_enum_dv_timings()
435 static int vpbe_s_std(struct vpbe_device *vpbe_dev, v4l2_std_id std_id) in vpbe_s_std() argument
437 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_s_std()
438 int out_index = vpbe_dev->current_out_index; in vpbe_s_std()
439 int sd_index = vpbe_dev->current_sd_index; in vpbe_s_std()
446 ret = vpbe_get_std_info(vpbe_dev, std_id); in vpbe_s_std()
450 mutex_lock(&vpbe_dev->lock); in vpbe_s_std()
452 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, in vpbe_s_std()
456 struct osd_state *osd_device = vpbe_dev->osd_device; in vpbe_s_std()
459 vpbe_dev->current_timings.left_margin); in vpbe_s_std()
461 vpbe_dev->current_timings.upper_margin); in vpbe_s_std()
463 mutex_unlock(&vpbe_dev->lock); in vpbe_s_std()
474 static int vpbe_g_std(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id) in vpbe_g_std() argument
476 struct vpbe_enc_mode_info *cur_timings = &vpbe_dev->current_timings; in vpbe_g_std()
477 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_g_std()
478 int out_index = vpbe_dev->current_out_index; in vpbe_g_std()
498 static int vpbe_set_mode(struct vpbe_device *vpbe_dev, in vpbe_set_mode() argument
502 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_set_mode()
505 int out_index = vpbe_dev->current_out_index; in vpbe_set_mode()
520 return vpbe_s_std(vpbe_dev, in vpbe_set_mode()
526 return vpbe_s_dv_timings(vpbe_dev, &dv_timings); in vpbe_set_mode()
535 mutex_lock(&vpbe_dev->lock); in vpbe_set_mode()
537 osd_device = vpbe_dev->osd_device; in vpbe_set_mode()
538 vpbe_dev->current_timings = *preset_mode; in vpbe_set_mode()
540 vpbe_dev->current_timings.left_margin); in vpbe_set_mode()
542 vpbe_dev->current_timings.upper_margin); in vpbe_set_mode()
544 mutex_unlock(&vpbe_dev->lock); in vpbe_set_mode()
548 static int vpbe_set_default_mode(struct vpbe_device *vpbe_dev) in vpbe_set_default_mode() argument
552 ret = vpbe_get_std_info_by_name(vpbe_dev, def_mode); in vpbe_set_default_mode()
557 return vpbe_set_mode(vpbe_dev, &vpbe_dev->current_timings); in vpbe_set_default_mode()
563 struct vpbe_device *vpbe_dev = data; in platform_device_get() local
566 vpbe_dev->osd_device = platform_get_drvdata(pdev); in platform_device_get()
568 vpbe_dev->venc_device = dev_get_platdata(&pdev->dev); in platform_device_get()
585 static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev) in vpbe_initialize() argument
602 if (!vpbe_dev || !dev) { in vpbe_initialize()
607 if (vpbe_dev->initialized) in vpbe_initialize()
610 mutex_lock(&vpbe_dev->lock); in vpbe_initialize()
612 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) { in vpbe_initialize()
614 vpbe_dev->dac_clk = clk_get(vpbe_dev->pdev, "vpss_dac"); in vpbe_initialize()
615 if (IS_ERR(vpbe_dev->dac_clk)) { in vpbe_initialize()
616 ret = PTR_ERR(vpbe_dev->dac_clk); in vpbe_initialize()
619 if (clk_prepare_enable(vpbe_dev->dac_clk)) { in vpbe_initialize()
621 clk_put(vpbe_dev->dac_clk); in vpbe_initialize()
630 ret = v4l2_device_register(dev, &vpbe_dev->v4l2_dev); in vpbe_initialize()
636 v4l2_info(&vpbe_dev->v4l2_dev, "vpbe v4l2 device registered\n"); in vpbe_initialize()
638 err = bus_for_each_dev(&platform_bus_type, NULL, vpbe_dev, in vpbe_initialize()
645 vpbe_dev->venc = venc_sub_dev_init(&vpbe_dev->v4l2_dev, in vpbe_initialize()
646 vpbe_dev->cfg->venc.module_name); in vpbe_initialize()
648 if (!vpbe_dev->venc) { in vpbe_initialize()
649 v4l2_err(&vpbe_dev->v4l2_dev, in vpbe_initialize()
655 osd_device = vpbe_dev->osd_device; in vpbe_initialize()
659 v4l2_err(&vpbe_dev->v4l2_dev, in vpbe_initialize()
670 num_encoders = vpbe_dev->cfg->num_ext_encoders + 1; in vpbe_initialize()
671 vpbe_dev->encoders = kmalloc_array(num_encoders, in vpbe_initialize()
672 sizeof(*vpbe_dev->encoders), in vpbe_initialize()
674 if (!vpbe_dev->encoders) { in vpbe_initialize()
679 i2c_adap = i2c_get_adapter(vpbe_dev->cfg->i2c_adapter_id); in vpbe_initialize()
680 for (i = 0; i < (vpbe_dev->cfg->num_ext_encoders + 1); i++) { in vpbe_initialize()
683 enc_subdev = &vpbe_dev->encoders[i]; in vpbe_initialize()
684 *enc_subdev = vpbe_dev->venc; in vpbe_initialize()
687 enc_info = &vpbe_dev->cfg->ext_encoders[i]; in vpbe_initialize()
689 enc_subdev = &vpbe_dev->encoders[i]; in vpbe_initialize()
691 &vpbe_dev->v4l2_dev, i2c_adap, in vpbe_initialize()
694 v4l2_info(&vpbe_dev->v4l2_dev, in vpbe_initialize()
698 v4l2_err(&vpbe_dev->v4l2_dev, "encoder %s failed to register", in vpbe_initialize()
704 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c encoders currently not supported"); in vpbe_initialize()
707 if ((strcmp(vpbe_dev->cfg->module_name, "dm365-vpbe-display") == 0) && in vpbe_initialize()
708 vpbe_dev->cfg->amp) { in vpbe_initialize()
709 amp_info = vpbe_dev->cfg->amp; in vpbe_initialize()
711 vpbe_dev->amp = v4l2_i2c_new_subdev_board( in vpbe_initialize()
712 &vpbe_dev->v4l2_dev, i2c_adap, in vpbe_initialize()
714 if (!vpbe_dev->amp) { in vpbe_initialize()
715 v4l2_err(&vpbe_dev->v4l2_dev, in vpbe_initialize()
721 v4l2_info(&vpbe_dev->v4l2_dev, in vpbe_initialize()
725 vpbe_dev->amp = NULL; in vpbe_initialize()
726 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c amplifiers currently not supported"); in vpbe_initialize()
729 vpbe_dev->amp = NULL; in vpbe_initialize()
733 vpbe_dev->current_sd_index = 0; in vpbe_initialize()
734 vpbe_dev->current_out_index = 0; in vpbe_initialize()
736 mutex_unlock(&vpbe_dev->lock); in vpbe_initialize()
739 ret = vpbe_set_default_output(vpbe_dev); in vpbe_initialize()
741 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default output %s", in vpbe_initialize()
747 ret = vpbe_set_default_mode(vpbe_dev); in vpbe_initialize()
749 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default mode %s", in vpbe_initialize()
753 vpbe_dev->initialized = 1; in vpbe_initialize()
758 kfree(vpbe_dev->encoders); in vpbe_initialize()
760 v4l2_device_unregister(&vpbe_dev->v4l2_dev); in vpbe_initialize()
762 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) { in vpbe_initialize()
763 clk_disable_unprepare(vpbe_dev->dac_clk); in vpbe_initialize()
764 clk_put(vpbe_dev->dac_clk); in vpbe_initialize()
767 mutex_unlock(&vpbe_dev->lock); in vpbe_initialize()
780 static void vpbe_deinitialize(struct device *dev, struct vpbe_device *vpbe_dev) in vpbe_deinitialize() argument
782 v4l2_device_unregister(&vpbe_dev->v4l2_dev); in vpbe_deinitialize()
783 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) { in vpbe_deinitialize()
784 clk_disable_unprepare(vpbe_dev->dac_clk); in vpbe_deinitialize()
785 clk_put(vpbe_dev->dac_clk); in vpbe_deinitialize()
788 kfree(vpbe_dev->amp); in vpbe_deinitialize()
789 kfree(vpbe_dev->encoders); in vpbe_deinitialize()
790 vpbe_dev->initialized = 0; in vpbe_deinitialize()
813 struct vpbe_device *vpbe_dev; in vpbe_probe() local
829 vpbe_dev = kzalloc(sizeof(*vpbe_dev), GFP_KERNEL); in vpbe_probe()
830 if (!vpbe_dev) in vpbe_probe()
833 vpbe_dev->cfg = cfg; in vpbe_probe()
834 vpbe_dev->ops = vpbe_dev_ops; in vpbe_probe()
835 vpbe_dev->pdev = &pdev->dev; in vpbe_probe()
838 vpbe_dev->current_timings = vpbe_dev->cfg->outputs[0].modes[0]; in vpbe_probe()
840 kfree(vpbe_dev); in vpbe_probe()
845 platform_set_drvdata(pdev, vpbe_dev); in vpbe_probe()
846 mutex_init(&vpbe_dev->lock); in vpbe_probe()
853 struct vpbe_device *vpbe_dev = platform_get_drvdata(device); in vpbe_remove() local
855 kfree(vpbe_dev); in vpbe_remove()