Lines Matching refs:vpbe_dev
63 vpbe_current_encoder_info(struct vpbe_device *vpbe_dev) in vpbe_current_encoder_info() argument
65 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_current_encoder_info()
66 int index = vpbe_dev->current_sd_index; in vpbe_current_encoder_info()
107 static int vpbe_g_cropcap(struct vpbe_device *vpbe_dev, in vpbe_g_cropcap() argument
114 cropcap->bounds.width = vpbe_dev->current_timings.xres; in vpbe_g_cropcap()
115 cropcap->bounds.height = vpbe_dev->current_timings.yres; in vpbe_g_cropcap()
129 static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev, in vpbe_enum_outputs() argument
132 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_enum_outputs()
144 static int vpbe_get_mode_info(struct vpbe_device *vpbe_dev, char *mode, in vpbe_get_mode_info() argument
147 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_get_mode_info()
158 vpbe_dev->current_timings = var; in vpbe_get_mode_info()
166 static int vpbe_get_current_mode_info(struct vpbe_device *vpbe_dev, in vpbe_get_current_mode_info() argument
172 *mode_info = vpbe_dev->current_timings; in vpbe_get_current_mode_info()
178 static int vpbe_get_std_info(struct vpbe_device *vpbe_dev, in vpbe_get_std_info() argument
181 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_get_std_info()
183 int curr_output = vpbe_dev->current_out_index; in vpbe_get_std_info()
186 for (i = 0; i < vpbe_dev->cfg->outputs[curr_output].num_modes; i++) { in vpbe_get_std_info()
190 vpbe_dev->current_timings = var; in vpbe_get_std_info()
198 static int vpbe_get_std_info_by_name(struct vpbe_device *vpbe_dev, in vpbe_get_std_info_by_name() argument
201 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_get_std_info_by_name()
203 int curr_output = vpbe_dev->current_out_index; in vpbe_get_std_info_by_name()
206 for (i = 0; i < vpbe_dev->cfg->outputs[curr_output].num_modes; i++) { in vpbe_get_std_info_by_name()
209 vpbe_dev->current_timings = var; in vpbe_get_std_info_by_name()
224 static int vpbe_set_output(struct vpbe_device *vpbe_dev, int index) in vpbe_set_output() argument
227 vpbe_current_encoder_info(vpbe_dev); in vpbe_set_output()
228 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_set_output()
229 struct venc_platform_data *venc_device = vpbe_dev->venc_device; in vpbe_set_output()
238 mutex_lock(&vpbe_dev->lock); in vpbe_set_output()
240 sd_index = vpbe_dev->current_sd_index; in vpbe_set_output()
267 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, in vpbe_set_output()
280 ret = vpbe_get_mode_info(vpbe_dev, in vpbe_set_output()
283 struct osd_state *osd_device = vpbe_dev->osd_device; in vpbe_set_output()
286 vpbe_dev->current_timings.left_margin); in vpbe_set_output()
288 vpbe_dev->current_timings.upper_margin); in vpbe_set_output()
289 vpbe_dev->current_sd_index = sd_index; in vpbe_set_output()
290 vpbe_dev->current_out_index = index; in vpbe_set_output()
293 mutex_unlock(&vpbe_dev->lock); in vpbe_set_output()
297 static int vpbe_set_default_output(struct vpbe_device *vpbe_dev) in vpbe_set_default_output() argument
299 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_set_default_output()
306 ret = vpbe_set_output(vpbe_dev, i); in vpbe_set_default_output()
308 vpbe_dev->current_out_index = i; in vpbe_set_default_output()
321 static unsigned int vpbe_get_output(struct vpbe_device *vpbe_dev) in vpbe_get_output() argument
323 return vpbe_dev->current_out_index; in vpbe_get_output()
332 static int vpbe_s_dv_timings(struct vpbe_device *vpbe_dev, in vpbe_s_dv_timings() argument
335 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_s_dv_timings()
336 int out_index = vpbe_dev->current_out_index; in vpbe_s_dv_timings()
338 int sd_index = vpbe_dev->current_sd_index; in vpbe_s_dv_timings()
354 vpbe_dev->current_timings = output->modes[i]; in vpbe_s_dv_timings()
355 mutex_lock(&vpbe_dev->lock); in vpbe_s_dv_timings()
357 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, in vpbe_s_dv_timings()
359 if (!ret && (vpbe_dev->amp != NULL)) { in vpbe_s_dv_timings()
361 ret = v4l2_subdev_call(vpbe_dev->amp, video, in vpbe_s_dv_timings()
366 struct osd_state *osd_device = vpbe_dev->osd_device; in vpbe_s_dv_timings()
369 vpbe_dev->current_timings.left_margin); in vpbe_s_dv_timings()
371 vpbe_dev->current_timings.upper_margin); in vpbe_s_dv_timings()
373 mutex_unlock(&vpbe_dev->lock); in vpbe_s_dv_timings()
384 static int vpbe_g_dv_timings(struct vpbe_device *vpbe_dev, in vpbe_g_dv_timings() argument
387 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_g_dv_timings()
388 int out_index = vpbe_dev->current_out_index; in vpbe_g_dv_timings()
394 if (vpbe_dev->current_timings.timings_type & in vpbe_g_dv_timings()
396 *dv_timings = vpbe_dev->current_timings.dv_timings; in vpbe_g_dv_timings()
409 static int vpbe_enum_dv_timings(struct vpbe_device *vpbe_dev, in vpbe_enum_dv_timings() argument
412 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_enum_dv_timings()
413 int out_index = vpbe_dev->current_out_index; in vpbe_enum_dv_timings()
441 static int vpbe_s_std(struct vpbe_device *vpbe_dev, v4l2_std_id std_id) in vpbe_s_std() argument
443 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_s_std()
444 int out_index = vpbe_dev->current_out_index; in vpbe_s_std()
445 int sd_index = vpbe_dev->current_sd_index; in vpbe_s_std()
452 ret = vpbe_get_std_info(vpbe_dev, std_id); in vpbe_s_std()
456 mutex_lock(&vpbe_dev->lock); in vpbe_s_std()
458 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, in vpbe_s_std()
462 struct osd_state *osd_device = vpbe_dev->osd_device; in vpbe_s_std()
465 vpbe_dev->current_timings.left_margin); in vpbe_s_std()
467 vpbe_dev->current_timings.upper_margin); in vpbe_s_std()
469 mutex_unlock(&vpbe_dev->lock); in vpbe_s_std()
480 static int vpbe_g_std(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id) in vpbe_g_std() argument
482 struct vpbe_enc_mode_info *cur_timings = &vpbe_dev->current_timings; in vpbe_g_std()
483 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_g_std()
484 int out_index = vpbe_dev->current_out_index; in vpbe_g_std()
504 static int vpbe_set_mode(struct vpbe_device *vpbe_dev, in vpbe_set_mode() argument
508 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_set_mode()
511 int out_index = vpbe_dev->current_out_index; in vpbe_set_mode()
527 return vpbe_s_std(vpbe_dev, in vpbe_set_mode()
533 return vpbe_s_dv_timings(vpbe_dev, &dv_timings); in vpbe_set_mode()
542 mutex_lock(&vpbe_dev->lock); in vpbe_set_mode()
544 osd_device = vpbe_dev->osd_device; in vpbe_set_mode()
545 vpbe_dev->current_timings = *preset_mode; in vpbe_set_mode()
547 vpbe_dev->current_timings.left_margin); in vpbe_set_mode()
549 vpbe_dev->current_timings.upper_margin); in vpbe_set_mode()
551 mutex_unlock(&vpbe_dev->lock); in vpbe_set_mode()
556 static int vpbe_set_default_mode(struct vpbe_device *vpbe_dev) in vpbe_set_default_mode() argument
560 ret = vpbe_get_std_info_by_name(vpbe_dev, def_mode); in vpbe_set_default_mode()
565 return vpbe_set_mode(vpbe_dev, &vpbe_dev->current_timings); in vpbe_set_default_mode()
571 struct vpbe_device *vpbe_dev = data; in platform_device_get() local
574 vpbe_dev->osd_device = platform_get_drvdata(pdev); in platform_device_get()
576 vpbe_dev->venc_device = dev_get_platdata(&pdev->dev); in platform_device_get()
592 static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev) in vpbe_initialize() argument
609 if (NULL == vpbe_dev || NULL == dev) { in vpbe_initialize()
614 if (vpbe_dev->initialized) in vpbe_initialize()
617 mutex_lock(&vpbe_dev->lock); in vpbe_initialize()
619 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) { in vpbe_initialize()
621 vpbe_dev->dac_clk = clk_get(vpbe_dev->pdev, "vpss_dac"); in vpbe_initialize()
622 if (IS_ERR(vpbe_dev->dac_clk)) { in vpbe_initialize()
623 ret = PTR_ERR(vpbe_dev->dac_clk); in vpbe_initialize()
626 if (clk_prepare_enable(vpbe_dev->dac_clk)) { in vpbe_initialize()
628 clk_put(vpbe_dev->dac_clk); in vpbe_initialize()
637 ret = v4l2_device_register(dev, &vpbe_dev->v4l2_dev); in vpbe_initialize()
643 v4l2_info(&vpbe_dev->v4l2_dev, "vpbe v4l2 device registered\n"); in vpbe_initialize()
645 err = bus_for_each_dev(&platform_bus_type, NULL, vpbe_dev, in vpbe_initialize()
652 vpbe_dev->venc = venc_sub_dev_init(&vpbe_dev->v4l2_dev, in vpbe_initialize()
653 vpbe_dev->cfg->venc.module_name); in vpbe_initialize()
655 if (vpbe_dev->venc == NULL) { in vpbe_initialize()
656 v4l2_err(&vpbe_dev->v4l2_dev, in vpbe_initialize()
662 osd_device = vpbe_dev->osd_device; in vpbe_initialize()
667 v4l2_err(&vpbe_dev->v4l2_dev, in vpbe_initialize()
678 num_encoders = vpbe_dev->cfg->num_ext_encoders + 1; in vpbe_initialize()
679 vpbe_dev->encoders = kmalloc( in vpbe_initialize()
682 if (NULL == vpbe_dev->encoders) { in vpbe_initialize()
683 v4l2_err(&vpbe_dev->v4l2_dev, in vpbe_initialize()
689 i2c_adap = i2c_get_adapter(vpbe_dev->cfg->i2c_adapter_id); in vpbe_initialize()
690 for (i = 0; i < (vpbe_dev->cfg->num_ext_encoders + 1); i++) { in vpbe_initialize()
693 enc_subdev = &vpbe_dev->encoders[i]; in vpbe_initialize()
694 *enc_subdev = vpbe_dev->venc; in vpbe_initialize()
697 enc_info = &vpbe_dev->cfg->ext_encoders[i]; in vpbe_initialize()
699 enc_subdev = &vpbe_dev->encoders[i]; in vpbe_initialize()
701 &vpbe_dev->v4l2_dev, i2c_adap, in vpbe_initialize()
704 v4l2_info(&vpbe_dev->v4l2_dev, in vpbe_initialize()
708 v4l2_err(&vpbe_dev->v4l2_dev, "encoder %s" in vpbe_initialize()
715 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c encoders" in vpbe_initialize()
719 if ((strcmp(vpbe_dev->cfg->module_name, "dm365-vpbe-display") == 0) && in vpbe_initialize()
720 vpbe_dev->cfg->amp != NULL) { in vpbe_initialize()
721 amp_info = vpbe_dev->cfg->amp; in vpbe_initialize()
723 vpbe_dev->amp = v4l2_i2c_new_subdev_board( in vpbe_initialize()
724 &vpbe_dev->v4l2_dev, i2c_adap, in vpbe_initialize()
726 if (!vpbe_dev->amp) { in vpbe_initialize()
727 v4l2_err(&vpbe_dev->v4l2_dev, in vpbe_initialize()
733 v4l2_info(&vpbe_dev->v4l2_dev, in vpbe_initialize()
737 vpbe_dev->amp = NULL; in vpbe_initialize()
738 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c amplifiers" in vpbe_initialize()
742 vpbe_dev->amp = NULL; in vpbe_initialize()
746 vpbe_dev->current_sd_index = 0; in vpbe_initialize()
747 vpbe_dev->current_out_index = 0; in vpbe_initialize()
749 mutex_unlock(&vpbe_dev->lock); in vpbe_initialize()
752 ret = vpbe_set_default_output(vpbe_dev); in vpbe_initialize()
754 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default output %s", in vpbe_initialize()
760 ret = vpbe_set_default_mode(vpbe_dev); in vpbe_initialize()
762 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default mode %s", in vpbe_initialize()
766 vpbe_dev->initialized = 1; in vpbe_initialize()
771 kfree(vpbe_dev->encoders); in vpbe_initialize()
773 v4l2_device_unregister(&vpbe_dev->v4l2_dev); in vpbe_initialize()
775 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) { in vpbe_initialize()
776 clk_disable_unprepare(vpbe_dev->dac_clk); in vpbe_initialize()
777 clk_put(vpbe_dev->dac_clk); in vpbe_initialize()
780 mutex_unlock(&vpbe_dev->lock); in vpbe_initialize()
792 static void vpbe_deinitialize(struct device *dev, struct vpbe_device *vpbe_dev) in vpbe_deinitialize() argument
794 v4l2_device_unregister(&vpbe_dev->v4l2_dev); in vpbe_deinitialize()
795 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) { in vpbe_deinitialize()
796 clk_disable_unprepare(vpbe_dev->dac_clk); in vpbe_deinitialize()
797 clk_put(vpbe_dev->dac_clk); in vpbe_deinitialize()
800 kfree(vpbe_dev->amp); in vpbe_deinitialize()
801 kfree(vpbe_dev->encoders); in vpbe_deinitialize()
802 vpbe_dev->initialized = 0; in vpbe_deinitialize()
825 struct vpbe_device *vpbe_dev; in vpbe_probe() local
843 vpbe_dev = kzalloc(sizeof(*vpbe_dev), GFP_KERNEL); in vpbe_probe()
844 if (vpbe_dev == NULL) { in vpbe_probe()
849 vpbe_dev->cfg = cfg; in vpbe_probe()
850 vpbe_dev->ops = vpbe_dev_ops; in vpbe_probe()
851 vpbe_dev->pdev = &pdev->dev; in vpbe_probe()
854 vpbe_dev->current_timings = vpbe_dev->cfg->outputs[0].modes[0]; in vpbe_probe()
856 kfree(vpbe_dev); in vpbe_probe()
861 platform_set_drvdata(pdev, vpbe_dev); in vpbe_probe()
862 mutex_init(&vpbe_dev->lock); in vpbe_probe()
869 struct vpbe_device *vpbe_dev = platform_get_drvdata(device); in vpbe_remove() local
871 kfree(vpbe_dev); in vpbe_remove()