Lines Matching refs:vpbe_dev
51 vpbe_current_encoder_info(struct vpbe_device *vpbe_dev) in vpbe_current_encoder_info() argument
53 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_current_encoder_info()
54 int index = vpbe_dev->current_sd_index; in vpbe_current_encoder_info()
95 static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev, in vpbe_enum_outputs() argument
98 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_enum_outputs()
110 static int vpbe_get_mode_info(struct vpbe_device *vpbe_dev, char *mode, in vpbe_get_mode_info() argument
113 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_get_mode_info()
124 vpbe_dev->current_timings = var; in vpbe_get_mode_info()
132 static int vpbe_get_current_mode_info(struct vpbe_device *vpbe_dev, in vpbe_get_current_mode_info() argument
138 *mode_info = vpbe_dev->current_timings; in vpbe_get_current_mode_info()
144 static int vpbe_get_std_info(struct vpbe_device *vpbe_dev, in vpbe_get_std_info() argument
147 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_get_std_info()
149 int curr_output = vpbe_dev->current_out_index; in vpbe_get_std_info()
152 for (i = 0; i < vpbe_dev->cfg->outputs[curr_output].num_modes; i++) { in vpbe_get_std_info()
156 vpbe_dev->current_timings = var; in vpbe_get_std_info()
164 static int vpbe_get_std_info_by_name(struct vpbe_device *vpbe_dev, in vpbe_get_std_info_by_name() argument
167 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_get_std_info_by_name()
169 int curr_output = vpbe_dev->current_out_index; in vpbe_get_std_info_by_name()
172 for (i = 0; i < vpbe_dev->cfg->outputs[curr_output].num_modes; i++) { in vpbe_get_std_info_by_name()
175 vpbe_dev->current_timings = var; in vpbe_get_std_info_by_name()
190 static int vpbe_set_output(struct vpbe_device *vpbe_dev, int index) in vpbe_set_output() argument
193 vpbe_current_encoder_info(vpbe_dev); in vpbe_set_output()
194 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_set_output()
195 struct venc_platform_data *venc_device = vpbe_dev->venc_device; in vpbe_set_output()
203 mutex_lock(&vpbe_dev->lock); in vpbe_set_output()
205 sd_index = vpbe_dev->current_sd_index; in vpbe_set_output()
231 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, in vpbe_set_output()
244 ret = vpbe_get_mode_info(vpbe_dev, in vpbe_set_output()
247 struct osd_state *osd_device = vpbe_dev->osd_device; in vpbe_set_output()
250 vpbe_dev->current_timings.left_margin); in vpbe_set_output()
252 vpbe_dev->current_timings.upper_margin); in vpbe_set_output()
253 vpbe_dev->current_sd_index = sd_index; in vpbe_set_output()
254 vpbe_dev->current_out_index = index; in vpbe_set_output()
257 mutex_unlock(&vpbe_dev->lock); in vpbe_set_output()
261 static int vpbe_set_default_output(struct vpbe_device *vpbe_dev) in vpbe_set_default_output() argument
263 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_set_default_output()
269 int ret = vpbe_set_output(vpbe_dev, i); in vpbe_set_default_output()
272 vpbe_dev->current_out_index = i; in vpbe_set_default_output()
285 static unsigned int vpbe_get_output(struct vpbe_device *vpbe_dev) in vpbe_get_output() argument
287 return vpbe_dev->current_out_index; in vpbe_get_output()
296 static int vpbe_s_dv_timings(struct vpbe_device *vpbe_dev, in vpbe_s_dv_timings() argument
299 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_s_dv_timings()
300 int out_index = vpbe_dev->current_out_index; in vpbe_s_dv_timings()
302 int sd_index = vpbe_dev->current_sd_index; in vpbe_s_dv_timings()
318 vpbe_dev->current_timings = output->modes[i]; in vpbe_s_dv_timings()
319 mutex_lock(&vpbe_dev->lock); in vpbe_s_dv_timings()
321 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, in vpbe_s_dv_timings()
323 if (!ret && vpbe_dev->amp) { in vpbe_s_dv_timings()
325 ret = v4l2_subdev_call(vpbe_dev->amp, video, in vpbe_s_dv_timings()
330 struct osd_state *osd_device = vpbe_dev->osd_device; in vpbe_s_dv_timings()
333 vpbe_dev->current_timings.left_margin); in vpbe_s_dv_timings()
335 vpbe_dev->current_timings.upper_margin); in vpbe_s_dv_timings()
337 mutex_unlock(&vpbe_dev->lock); in vpbe_s_dv_timings()
348 static int vpbe_g_dv_timings(struct vpbe_device *vpbe_dev, in vpbe_g_dv_timings() argument
351 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_g_dv_timings()
352 int out_index = vpbe_dev->current_out_index; in vpbe_g_dv_timings()
358 if (vpbe_dev->current_timings.timings_type & in vpbe_g_dv_timings()
360 *dv_timings = vpbe_dev->current_timings.dv_timings; in vpbe_g_dv_timings()
373 static int vpbe_enum_dv_timings(struct vpbe_device *vpbe_dev, in vpbe_enum_dv_timings() argument
376 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_enum_dv_timings()
377 int out_index = vpbe_dev->current_out_index; in vpbe_enum_dv_timings()
405 static int vpbe_s_std(struct vpbe_device *vpbe_dev, v4l2_std_id std_id) in vpbe_s_std() argument
407 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_s_std()
408 int out_index = vpbe_dev->current_out_index; in vpbe_s_std()
409 int sd_index = vpbe_dev->current_sd_index; in vpbe_s_std()
416 ret = vpbe_get_std_info(vpbe_dev, std_id); in vpbe_s_std()
420 mutex_lock(&vpbe_dev->lock); in vpbe_s_std()
422 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, in vpbe_s_std()
426 struct osd_state *osd_device = vpbe_dev->osd_device; in vpbe_s_std()
429 vpbe_dev->current_timings.left_margin); in vpbe_s_std()
431 vpbe_dev->current_timings.upper_margin); in vpbe_s_std()
433 mutex_unlock(&vpbe_dev->lock); in vpbe_s_std()
444 static int vpbe_g_std(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id) in vpbe_g_std() argument
446 struct vpbe_enc_mode_info *cur_timings = &vpbe_dev->current_timings; in vpbe_g_std()
447 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_g_std()
448 int out_index = vpbe_dev->current_out_index; in vpbe_g_std()
468 static int vpbe_set_mode(struct vpbe_device *vpbe_dev, in vpbe_set_mode() argument
472 struct vpbe_config *cfg = vpbe_dev->cfg; in vpbe_set_mode()
475 int out_index = vpbe_dev->current_out_index; in vpbe_set_mode()
490 return vpbe_s_std(vpbe_dev, in vpbe_set_mode()
496 return vpbe_s_dv_timings(vpbe_dev, &dv_timings); in vpbe_set_mode()
505 mutex_lock(&vpbe_dev->lock); in vpbe_set_mode()
507 osd_device = vpbe_dev->osd_device; in vpbe_set_mode()
508 vpbe_dev->current_timings = *preset_mode; in vpbe_set_mode()
510 vpbe_dev->current_timings.left_margin); in vpbe_set_mode()
512 vpbe_dev->current_timings.upper_margin); in vpbe_set_mode()
514 mutex_unlock(&vpbe_dev->lock); in vpbe_set_mode()
518 static int vpbe_set_default_mode(struct vpbe_device *vpbe_dev) in vpbe_set_default_mode() argument
522 ret = vpbe_get_std_info_by_name(vpbe_dev, def_mode); in vpbe_set_default_mode()
527 return vpbe_set_mode(vpbe_dev, &vpbe_dev->current_timings); in vpbe_set_default_mode()
533 struct vpbe_device *vpbe_dev = data; in platform_device_get() local
536 vpbe_dev->osd_device = platform_get_drvdata(pdev); in platform_device_get()
538 vpbe_dev->venc_device = dev_get_platdata(&pdev->dev); in platform_device_get()
555 static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev) in vpbe_initialize() argument
572 if (!vpbe_dev || !dev) { in vpbe_initialize()
577 if (vpbe_dev->initialized) in vpbe_initialize()
580 mutex_lock(&vpbe_dev->lock); in vpbe_initialize()
582 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) { in vpbe_initialize()
584 vpbe_dev->dac_clk = clk_get(vpbe_dev->pdev, "vpss_dac"); in vpbe_initialize()
585 if (IS_ERR(vpbe_dev->dac_clk)) { in vpbe_initialize()
586 ret = PTR_ERR(vpbe_dev->dac_clk); in vpbe_initialize()
589 if (clk_prepare_enable(vpbe_dev->dac_clk)) { in vpbe_initialize()
591 clk_put(vpbe_dev->dac_clk); in vpbe_initialize()
600 ret = v4l2_device_register(dev, &vpbe_dev->v4l2_dev); in vpbe_initialize()
606 v4l2_info(&vpbe_dev->v4l2_dev, "vpbe v4l2 device registered\n"); in vpbe_initialize()
608 err = bus_for_each_dev(&platform_bus_type, NULL, vpbe_dev, in vpbe_initialize()
615 vpbe_dev->venc = venc_sub_dev_init(&vpbe_dev->v4l2_dev, in vpbe_initialize()
616 vpbe_dev->cfg->venc.module_name); in vpbe_initialize()
618 if (!vpbe_dev->venc) { in vpbe_initialize()
619 v4l2_err(&vpbe_dev->v4l2_dev, in vpbe_initialize()
625 osd_device = vpbe_dev->osd_device; in vpbe_initialize()
629 v4l2_err(&vpbe_dev->v4l2_dev, in vpbe_initialize()
640 num_encoders = vpbe_dev->cfg->num_ext_encoders + 1; in vpbe_initialize()
641 vpbe_dev->encoders = kmalloc_array(num_encoders, in vpbe_initialize()
642 sizeof(*vpbe_dev->encoders), in vpbe_initialize()
644 if (!vpbe_dev->encoders) { in vpbe_initialize()
649 i2c_adap = i2c_get_adapter(vpbe_dev->cfg->i2c_adapter_id); in vpbe_initialize()
650 for (i = 0; i < (vpbe_dev->cfg->num_ext_encoders + 1); i++) { in vpbe_initialize()
653 enc_subdev = &vpbe_dev->encoders[i]; in vpbe_initialize()
654 *enc_subdev = vpbe_dev->venc; in vpbe_initialize()
657 enc_info = &vpbe_dev->cfg->ext_encoders[i]; in vpbe_initialize()
659 enc_subdev = &vpbe_dev->encoders[i]; in vpbe_initialize()
661 &vpbe_dev->v4l2_dev, i2c_adap, in vpbe_initialize()
664 v4l2_info(&vpbe_dev->v4l2_dev, in vpbe_initialize()
668 v4l2_err(&vpbe_dev->v4l2_dev, "encoder %s failed to register", in vpbe_initialize()
674 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c encoders currently not supported"); in vpbe_initialize()
677 if ((strcmp(vpbe_dev->cfg->module_name, "dm365-vpbe-display") == 0) && in vpbe_initialize()
678 vpbe_dev->cfg->amp) { in vpbe_initialize()
679 amp_info = vpbe_dev->cfg->amp; in vpbe_initialize()
681 vpbe_dev->amp = v4l2_i2c_new_subdev_board( in vpbe_initialize()
682 &vpbe_dev->v4l2_dev, i2c_adap, in vpbe_initialize()
684 if (!vpbe_dev->amp) { in vpbe_initialize()
685 v4l2_err(&vpbe_dev->v4l2_dev, in vpbe_initialize()
691 v4l2_info(&vpbe_dev->v4l2_dev, in vpbe_initialize()
695 vpbe_dev->amp = NULL; in vpbe_initialize()
696 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c amplifiers currently not supported"); in vpbe_initialize()
699 vpbe_dev->amp = NULL; in vpbe_initialize()
703 vpbe_dev->current_sd_index = 0; in vpbe_initialize()
704 vpbe_dev->current_out_index = 0; in vpbe_initialize()
706 mutex_unlock(&vpbe_dev->lock); in vpbe_initialize()
709 ret = vpbe_set_default_output(vpbe_dev); in vpbe_initialize()
711 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default output %s", in vpbe_initialize()
717 ret = vpbe_set_default_mode(vpbe_dev); in vpbe_initialize()
719 v4l2_err(&vpbe_dev->v4l2_dev, "Failed to set default mode %s", in vpbe_initialize()
723 vpbe_dev->initialized = 1; in vpbe_initialize()
728 mutex_lock(&vpbe_dev->lock); in vpbe_initialize()
729 kfree(vpbe_dev->amp); in vpbe_initialize()
731 kfree(vpbe_dev->encoders); in vpbe_initialize()
733 v4l2_device_unregister(&vpbe_dev->v4l2_dev); in vpbe_initialize()
735 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) { in vpbe_initialize()
736 clk_disable_unprepare(vpbe_dev->dac_clk); in vpbe_initialize()
737 clk_put(vpbe_dev->dac_clk); in vpbe_initialize()
740 mutex_unlock(&vpbe_dev->lock); in vpbe_initialize()
753 static void vpbe_deinitialize(struct device *dev, struct vpbe_device *vpbe_dev) in vpbe_deinitialize() argument
755 v4l2_device_unregister(&vpbe_dev->v4l2_dev); in vpbe_deinitialize()
756 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) { in vpbe_deinitialize()
757 clk_disable_unprepare(vpbe_dev->dac_clk); in vpbe_deinitialize()
758 clk_put(vpbe_dev->dac_clk); in vpbe_deinitialize()
761 kfree(vpbe_dev->amp); in vpbe_deinitialize()
762 kfree(vpbe_dev->encoders); in vpbe_deinitialize()
763 vpbe_dev->initialized = 0; in vpbe_deinitialize()
785 struct vpbe_device *vpbe_dev; in vpbe_probe() local
801 vpbe_dev = kzalloc(sizeof(*vpbe_dev), GFP_KERNEL); in vpbe_probe()
802 if (!vpbe_dev) in vpbe_probe()
805 vpbe_dev->cfg = cfg; in vpbe_probe()
806 vpbe_dev->ops = vpbe_dev_ops; in vpbe_probe()
807 vpbe_dev->pdev = &pdev->dev; in vpbe_probe()
810 vpbe_dev->current_timings = vpbe_dev->cfg->outputs[0].modes[0]; in vpbe_probe()
812 kfree(vpbe_dev); in vpbe_probe()
817 platform_set_drvdata(pdev, vpbe_dev); in vpbe_probe()
818 mutex_init(&vpbe_dev->lock); in vpbe_probe()
825 struct vpbe_device *vpbe_dev = platform_get_drvdata(device); in vpbe_remove() local
827 kfree(vpbe_dev); in vpbe_remove()