1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2010 Texas Instruments Inc
5 #include <linux/kernel.h>
6 #include <linux/init.h>
7 #include <linux/module.h>
8 #include <linux/errno.h>
10 #include <linux/string.h>
11 #include <linux/wait.h>
12 #include <linux/time.h>
13 #include <linux/platform_device.h>
15 #include <linux/slab.h>
16 #include <linux/clk.h>
17 #include <linux/err.h>
19 #include <media/v4l2-device.h>
20 #include <media/davinci/vpbe_types.h>
21 #include <media/davinci/vpbe.h>
22 #include <media/davinci/vpss.h>
23 #include <media/davinci/vpbe_venc.h>
25 #define VPBE_DEFAULT_OUTPUT "Composite"
26 #define VPBE_DEFAULT_MODE "ntsc"
28 static char *def_output
= VPBE_DEFAULT_OUTPUT
;
29 static char *def_mode
= VPBE_DEFAULT_MODE
;
32 module_param(def_output
, charp
, S_IRUGO
);
33 module_param(def_mode
, charp
, S_IRUGO
);
34 module_param(debug
, int, 0644);
36 MODULE_PARM_DESC(def_output
, "vpbe output name (default:Composite)");
37 MODULE_PARM_DESC(def_mode
, "vpbe output mode name (default:ntsc");
38 MODULE_PARM_DESC(debug
, "Debug level 0-1");
40 MODULE_DESCRIPTION("TI DMXXX VPBE Display controller");
41 MODULE_LICENSE("GPL");
42 MODULE_AUTHOR("Texas Instruments");
45 * vpbe_current_encoder_info - Get config info for current encoder
46 * @vpbe_dev: vpbe device ptr
48 * Return ptr to current encoder config info
50 static struct encoder_config_info
*
51 vpbe_current_encoder_info(struct vpbe_device
*vpbe_dev
)
53 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
54 int index
= vpbe_dev
->current_sd_index
;
56 return ((index
== 0) ? &cfg
->venc
:
57 &cfg
->ext_encoders
[index
-1]);
61 * vpbe_find_encoder_sd_index - Given a name find encoder sd index
63 * @cfg: ptr to vpbe cfg
64 * @index: index used by application
66 * Return sd index of the encoder
68 static int vpbe_find_encoder_sd_index(struct vpbe_config
*cfg
,
71 char *encoder_name
= cfg
->outputs
[index
].subdev_name
;
74 /* Venc is always first */
75 if (!strcmp(encoder_name
, cfg
->venc
.module_name
))
78 for (i
= 0; i
< cfg
->num_ext_encoders
; i
++) {
79 if (!strcmp(encoder_name
,
80 cfg
->ext_encoders
[i
].module_name
))
88 * vpbe_enum_outputs - enumerate outputs
89 * @vpbe_dev: vpbe device ptr
90 * @output: ptr to v4l2_output structure
92 * Enumerates the outputs available at the vpbe display
93 * returns the status, -EINVAL if end of output list
95 static int vpbe_enum_outputs(struct vpbe_device
*vpbe_dev
,
96 struct v4l2_output
*output
)
98 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
99 unsigned int temp_index
= output
->index
;
101 if (temp_index
>= cfg
->num_outputs
)
104 *output
= cfg
->outputs
[temp_index
].output
;
105 output
->index
= temp_index
;
110 static int vpbe_get_mode_info(struct vpbe_device
*vpbe_dev
, char *mode
,
113 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
114 struct vpbe_enc_mode_info var
;
115 int curr_output
= output_index
;
121 for (i
= 0; i
< cfg
->outputs
[curr_output
].num_modes
; i
++) {
122 var
= cfg
->outputs
[curr_output
].modes
[i
];
123 if (!strcmp(mode
, var
.name
)) {
124 vpbe_dev
->current_timings
= var
;
132 static int vpbe_get_current_mode_info(struct vpbe_device
*vpbe_dev
,
133 struct vpbe_enc_mode_info
*mode_info
)
138 *mode_info
= vpbe_dev
->current_timings
;
143 /* Get std by std id */
144 static int vpbe_get_std_info(struct vpbe_device
*vpbe_dev
,
147 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
148 struct vpbe_enc_mode_info var
;
149 int curr_output
= vpbe_dev
->current_out_index
;
152 for (i
= 0; i
< vpbe_dev
->cfg
->outputs
[curr_output
].num_modes
; i
++) {
153 var
= cfg
->outputs
[curr_output
].modes
[i
];
154 if ((var
.timings_type
& VPBE_ENC_STD
) &&
155 (var
.std_id
& std_id
)) {
156 vpbe_dev
->current_timings
= var
;
164 static int vpbe_get_std_info_by_name(struct vpbe_device
*vpbe_dev
,
167 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
168 struct vpbe_enc_mode_info var
;
169 int curr_output
= vpbe_dev
->current_out_index
;
172 for (i
= 0; i
< vpbe_dev
->cfg
->outputs
[curr_output
].num_modes
; i
++) {
173 var
= cfg
->outputs
[curr_output
].modes
[i
];
174 if (!strcmp(var
.name
, std_name
)) {
175 vpbe_dev
->current_timings
= var
;
184 * vpbe_set_output - Set output
185 * @vpbe_dev: vpbe device ptr
186 * @index: index of output
188 * Set vpbe output to the output specified by the index
190 static int vpbe_set_output(struct vpbe_device
*vpbe_dev
, int index
)
192 struct encoder_config_info
*curr_enc_info
=
193 vpbe_current_encoder_info(vpbe_dev
);
194 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
195 struct venc_platform_data
*venc_device
= vpbe_dev
->venc_device
;
200 if (index
>= cfg
->num_outputs
)
203 mutex_lock(&vpbe_dev
->lock
);
205 sd_index
= vpbe_dev
->current_sd_index
;
206 enc_out_index
= cfg
->outputs
[index
].output
.index
;
208 * Currently we switch the encoder based on output selected
209 * by the application. If media controller is implemented later
210 * there is will be an API added to setup_link between venc
211 * and external encoder. So in that case below comparison always
212 * match and encoder will not be switched. But if application
213 * chose not to use media controller, then this provides current
214 * way of switching encoder at the venc output.
216 if (strcmp(curr_enc_info
->module_name
,
217 cfg
->outputs
[index
].subdev_name
)) {
218 /* Need to switch the encoder at the output */
219 sd_index
= vpbe_find_encoder_sd_index(cfg
, index
);
225 ret
= venc_device
->setup_if_config(cfg
->outputs
[index
].if_params
);
230 /* Set output at the encoder */
231 ret
= v4l2_subdev_call(vpbe_dev
->encoders
[sd_index
], video
,
232 s_routing
, 0, enc_out_index
, 0);
237 * It is assumed that venc or external encoder will set a default
238 * mode in the sub device. For external encoder or LCD pannel output,
239 * we also need to set up the lcd port for the required mode. So setup
240 * the lcd port for the default mode that is configured in the board
241 * arch/arm/mach-davinci/board-dm355-evm.setup file for the external
244 ret
= vpbe_get_mode_info(vpbe_dev
,
245 cfg
->outputs
[index
].default_mode
, index
);
247 struct osd_state
*osd_device
= vpbe_dev
->osd_device
;
249 osd_device
->ops
.set_left_margin(osd_device
,
250 vpbe_dev
->current_timings
.left_margin
);
251 osd_device
->ops
.set_top_margin(osd_device
,
252 vpbe_dev
->current_timings
.upper_margin
);
253 vpbe_dev
->current_sd_index
= sd_index
;
254 vpbe_dev
->current_out_index
= index
;
257 mutex_unlock(&vpbe_dev
->lock
);
261 static int vpbe_set_default_output(struct vpbe_device
*vpbe_dev
)
263 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
266 for (i
= 0; i
< cfg
->num_outputs
; i
++) {
267 if (!strcmp(def_output
,
268 cfg
->outputs
[i
].output
.name
)) {
269 int ret
= vpbe_set_output(vpbe_dev
, i
);
272 vpbe_dev
->current_out_index
= i
;
280 * vpbe_get_output - Get output
281 * @vpbe_dev: vpbe device ptr
283 * return current vpbe output to the the index
285 static unsigned int vpbe_get_output(struct vpbe_device
*vpbe_dev
)
287 return vpbe_dev
->current_out_index
;
291 * vpbe_s_dv_timings - Set the given preset timings in the encoder
293 * Sets the timings if supported by the current encoder. Return the status.
294 * 0 - success & -EINVAL on error
296 static int vpbe_s_dv_timings(struct vpbe_device
*vpbe_dev
,
297 struct v4l2_dv_timings
*dv_timings
)
299 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
300 int out_index
= vpbe_dev
->current_out_index
;
301 struct vpbe_output
*output
= &cfg
->outputs
[out_index
];
302 int sd_index
= vpbe_dev
->current_sd_index
;
306 if (!(cfg
->outputs
[out_index
].output
.capabilities
&
307 V4L2_OUT_CAP_DV_TIMINGS
))
310 for (i
= 0; i
< output
->num_modes
; i
++) {
311 if (output
->modes
[i
].timings_type
== VPBE_ENC_DV_TIMINGS
&&
312 !memcmp(&output
->modes
[i
].dv_timings
,
313 dv_timings
, sizeof(*dv_timings
)))
316 if (i
>= output
->num_modes
)
318 vpbe_dev
->current_timings
= output
->modes
[i
];
319 mutex_lock(&vpbe_dev
->lock
);
321 ret
= v4l2_subdev_call(vpbe_dev
->encoders
[sd_index
], video
,
322 s_dv_timings
, dv_timings
);
323 if (!ret
&& vpbe_dev
->amp
) {
324 /* Call amplifier subdevice */
325 ret
= v4l2_subdev_call(vpbe_dev
->amp
, video
,
326 s_dv_timings
, dv_timings
);
328 /* set the lcd controller output for the given mode */
330 struct osd_state
*osd_device
= vpbe_dev
->osd_device
;
332 osd_device
->ops
.set_left_margin(osd_device
,
333 vpbe_dev
->current_timings
.left_margin
);
334 osd_device
->ops
.set_top_margin(osd_device
,
335 vpbe_dev
->current_timings
.upper_margin
);
337 mutex_unlock(&vpbe_dev
->lock
);
343 * vpbe_g_dv_timings - Get the timings in the current encoder
345 * Get the timings in the current encoder. Return the status. 0 - success
348 static int vpbe_g_dv_timings(struct vpbe_device
*vpbe_dev
,
349 struct v4l2_dv_timings
*dv_timings
)
351 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
352 int out_index
= vpbe_dev
->current_out_index
;
354 if (!(cfg
->outputs
[out_index
].output
.capabilities
&
355 V4L2_OUT_CAP_DV_TIMINGS
))
358 if (vpbe_dev
->current_timings
.timings_type
&
359 VPBE_ENC_DV_TIMINGS
) {
360 *dv_timings
= vpbe_dev
->current_timings
.dv_timings
;
368 * vpbe_enum_dv_timings - Enumerate the dv timings in the current encoder
370 * Get the timings in the current encoder. Return the status. 0 - success
373 static int vpbe_enum_dv_timings(struct vpbe_device
*vpbe_dev
,
374 struct v4l2_enum_dv_timings
*timings
)
376 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
377 int out_index
= vpbe_dev
->current_out_index
;
378 struct vpbe_output
*output
= &cfg
->outputs
[out_index
];
382 if (!(output
->output
.capabilities
& V4L2_OUT_CAP_DV_TIMINGS
))
385 for (i
= 0; i
< output
->num_modes
; i
++) {
386 if (output
->modes
[i
].timings_type
== VPBE_ENC_DV_TIMINGS
) {
387 if (j
== timings
->index
)
393 if (i
== output
->num_modes
)
395 timings
->timings
= output
->modes
[i
].dv_timings
;
400 * vpbe_s_std - Set the given standard in the encoder
402 * Sets the standard if supported by the current encoder. Return the status.
403 * 0 - success & -EINVAL on error
405 static int vpbe_s_std(struct vpbe_device
*vpbe_dev
, v4l2_std_id std_id
)
407 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
408 int out_index
= vpbe_dev
->current_out_index
;
409 int sd_index
= vpbe_dev
->current_sd_index
;
412 if (!(cfg
->outputs
[out_index
].output
.capabilities
&
416 ret
= vpbe_get_std_info(vpbe_dev
, std_id
);
420 mutex_lock(&vpbe_dev
->lock
);
422 ret
= v4l2_subdev_call(vpbe_dev
->encoders
[sd_index
], video
,
423 s_std_output
, std_id
);
424 /* set the lcd controller output for the given mode */
426 struct osd_state
*osd_device
= vpbe_dev
->osd_device
;
428 osd_device
->ops
.set_left_margin(osd_device
,
429 vpbe_dev
->current_timings
.left_margin
);
430 osd_device
->ops
.set_top_margin(osd_device
,
431 vpbe_dev
->current_timings
.upper_margin
);
433 mutex_unlock(&vpbe_dev
->lock
);
439 * vpbe_g_std - Get the standard in the current encoder
441 * Get the standard in the current encoder. Return the status. 0 - success
444 static int vpbe_g_std(struct vpbe_device
*vpbe_dev
, v4l2_std_id
*std_id
)
446 struct vpbe_enc_mode_info
*cur_timings
= &vpbe_dev
->current_timings
;
447 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
448 int out_index
= vpbe_dev
->current_out_index
;
450 if (!(cfg
->outputs
[out_index
].output
.capabilities
& V4L2_OUT_CAP_STD
))
453 if (cur_timings
->timings_type
& VPBE_ENC_STD
) {
454 *std_id
= cur_timings
->std_id
;
462 * vpbe_set_mode - Set mode in the current encoder using mode info
464 * Use the mode string to decide what timings to set in the encoder
465 * This is typically useful when fbset command is used to change the current
466 * timings by specifying a string to indicate the timings.
468 static int vpbe_set_mode(struct vpbe_device
*vpbe_dev
,
469 struct vpbe_enc_mode_info
*mode_info
)
471 struct vpbe_enc_mode_info
*preset_mode
= NULL
;
472 struct vpbe_config
*cfg
= vpbe_dev
->cfg
;
473 struct v4l2_dv_timings dv_timings
;
474 struct osd_state
*osd_device
;
475 int out_index
= vpbe_dev
->current_out_index
;
478 if (!mode_info
|| !mode_info
->name
)
481 for (i
= 0; i
< cfg
->outputs
[out_index
].num_modes
; i
++) {
482 if (!strcmp(mode_info
->name
,
483 cfg
->outputs
[out_index
].modes
[i
].name
)) {
484 preset_mode
= &cfg
->outputs
[out_index
].modes
[i
];
486 * it may be one of the 3 timings type. Check and
489 if (preset_mode
->timings_type
& VPBE_ENC_STD
)
490 return vpbe_s_std(vpbe_dev
,
491 preset_mode
->std_id
);
492 if (preset_mode
->timings_type
&
493 VPBE_ENC_DV_TIMINGS
) {
495 preset_mode
->dv_timings
;
496 return vpbe_s_dv_timings(vpbe_dev
, &dv_timings
);
501 /* Only custom timing should reach here */
505 mutex_lock(&vpbe_dev
->lock
);
507 osd_device
= vpbe_dev
->osd_device
;
508 vpbe_dev
->current_timings
= *preset_mode
;
509 osd_device
->ops
.set_left_margin(osd_device
,
510 vpbe_dev
->current_timings
.left_margin
);
511 osd_device
->ops
.set_top_margin(osd_device
,
512 vpbe_dev
->current_timings
.upper_margin
);
514 mutex_unlock(&vpbe_dev
->lock
);
518 static int vpbe_set_default_mode(struct vpbe_device
*vpbe_dev
)
522 ret
= vpbe_get_std_info_by_name(vpbe_dev
, def_mode
);
526 /* set the default mode in the encoder */
527 return vpbe_set_mode(vpbe_dev
, &vpbe_dev
->current_timings
);
530 static int platform_device_get(struct device
*dev
, void *data
)
532 struct platform_device
*pdev
= to_platform_device(dev
);
533 struct vpbe_device
*vpbe_dev
= data
;
535 if (strstr(pdev
->name
, "vpbe-osd"))
536 vpbe_dev
->osd_device
= platform_get_drvdata(pdev
);
537 if (strstr(pdev
->name
, "vpbe-venc"))
538 vpbe_dev
->venc_device
= dev_get_platdata(&pdev
->dev
);
544 * vpbe_initialize() - Initialize the vpbe display controller
545 * @dev: Master and slave device ptr
546 * @vpbe_dev: vpbe device ptr
548 * Master frame buffer device drivers calls this to initialize vpbe
549 * display controller. This will then registers v4l2 device and the sub
550 * devices and sets a current encoder sub device for display. v4l2 display
551 * device driver is the master and frame buffer display device driver is
552 * the slave. Frame buffer display driver checks the initialized during
553 * probe and exit if not initialized. Returns status.
555 static int vpbe_initialize(struct device
*dev
, struct vpbe_device
*vpbe_dev
)
557 struct encoder_config_info
*enc_info
;
558 struct amp_config_info
*amp_info
;
559 struct v4l2_subdev
**enc_subdev
;
560 struct osd_state
*osd_device
;
561 struct i2c_adapter
*i2c_adap
;
568 * v4l2 abd FBDev frame buffer devices will get the vpbe_dev pointer
569 * from the platform device by iteration of platform drivers and
570 * matching with device name
572 if (!vpbe_dev
|| !dev
) {
573 printk(KERN_ERR
"Null device pointers.\n");
577 if (vpbe_dev
->initialized
)
580 mutex_lock(&vpbe_dev
->lock
);
582 if (strcmp(vpbe_dev
->cfg
->module_name
, "dm644x-vpbe-display") != 0) {
583 /* We have dac clock available for platform */
584 vpbe_dev
->dac_clk
= clk_get(vpbe_dev
->pdev
, "vpss_dac");
585 if (IS_ERR(vpbe_dev
->dac_clk
)) {
586 ret
= PTR_ERR(vpbe_dev
->dac_clk
);
587 goto fail_mutex_unlock
;
589 if (clk_prepare_enable(vpbe_dev
->dac_clk
)) {
591 clk_put(vpbe_dev
->dac_clk
);
592 goto fail_mutex_unlock
;
596 /* first enable vpss clocks */
597 vpss_enable_clock(VPSS_VPBE_CLOCK
, 1);
599 /* First register a v4l2 device */
600 ret
= v4l2_device_register(dev
, &vpbe_dev
->v4l2_dev
);
602 v4l2_err(dev
->driver
,
603 "Unable to register v4l2 device.\n");
606 v4l2_info(&vpbe_dev
->v4l2_dev
, "vpbe v4l2 device registered\n");
608 err
= bus_for_each_dev(&platform_bus_type
, NULL
, vpbe_dev
,
609 platform_device_get
);
612 goto fail_dev_unregister
;
615 vpbe_dev
->venc
= venc_sub_dev_init(&vpbe_dev
->v4l2_dev
,
616 vpbe_dev
->cfg
->venc
.module_name
);
617 /* register venc sub device */
618 if (!vpbe_dev
->venc
) {
619 v4l2_err(&vpbe_dev
->v4l2_dev
,
620 "vpbe unable to init venc sub device\n");
622 goto fail_dev_unregister
;
624 /* initialize osd device */
625 osd_device
= vpbe_dev
->osd_device
;
626 if (osd_device
->ops
.initialize
) {
627 err
= osd_device
->ops
.initialize(osd_device
);
629 v4l2_err(&vpbe_dev
->v4l2_dev
,
630 "unable to initialize the OSD device");
632 goto fail_dev_unregister
;
637 * Register any external encoders that are configured. At index 0 we
638 * store venc sd index.
640 num_encoders
= vpbe_dev
->cfg
->num_ext_encoders
+ 1;
641 vpbe_dev
->encoders
= kmalloc_array(num_encoders
,
642 sizeof(*vpbe_dev
->encoders
),
644 if (!vpbe_dev
->encoders
) {
646 goto fail_dev_unregister
;
649 i2c_adap
= i2c_get_adapter(vpbe_dev
->cfg
->i2c_adapter_id
);
650 for (i
= 0; i
< (vpbe_dev
->cfg
->num_ext_encoders
+ 1); i
++) {
652 /* venc is at index 0 */
653 enc_subdev
= &vpbe_dev
->encoders
[i
];
654 *enc_subdev
= vpbe_dev
->venc
;
657 enc_info
= &vpbe_dev
->cfg
->ext_encoders
[i
];
658 if (enc_info
->is_i2c
) {
659 enc_subdev
= &vpbe_dev
->encoders
[i
];
660 *enc_subdev
= v4l2_i2c_new_subdev_board(
661 &vpbe_dev
->v4l2_dev
, i2c_adap
,
662 &enc_info
->board_info
, NULL
);
664 v4l2_info(&vpbe_dev
->v4l2_dev
,
665 "v4l2 sub device %s registered\n",
666 enc_info
->module_name
);
668 v4l2_err(&vpbe_dev
->v4l2_dev
, "encoder %s failed to register",
669 enc_info
->module_name
);
671 goto fail_kfree_encoders
;
674 v4l2_warn(&vpbe_dev
->v4l2_dev
, "non-i2c encoders currently not supported");
676 /* Add amplifier subdevice for dm365 */
677 if ((strcmp(vpbe_dev
->cfg
->module_name
, "dm365-vpbe-display") == 0) &&
678 vpbe_dev
->cfg
->amp
) {
679 amp_info
= vpbe_dev
->cfg
->amp
;
680 if (amp_info
->is_i2c
) {
681 vpbe_dev
->amp
= v4l2_i2c_new_subdev_board(
682 &vpbe_dev
->v4l2_dev
, i2c_adap
,
683 &_info
->board_info
, NULL
);
684 if (!vpbe_dev
->amp
) {
685 v4l2_err(&vpbe_dev
->v4l2_dev
,
686 "amplifier %s failed to register",
687 amp_info
->module_name
);
689 goto fail_kfree_encoders
;
691 v4l2_info(&vpbe_dev
->v4l2_dev
,
692 "v4l2 sub device %s registered\n",
693 amp_info
->module_name
);
695 vpbe_dev
->amp
= NULL
;
696 v4l2_warn(&vpbe_dev
->v4l2_dev
, "non-i2c amplifiers currently not supported");
699 vpbe_dev
->amp
= NULL
;
702 /* set the current encoder and output to that of venc by default */
703 vpbe_dev
->current_sd_index
= 0;
704 vpbe_dev
->current_out_index
= 0;
706 mutex_unlock(&vpbe_dev
->lock
);
708 printk(KERN_NOTICE
"Setting default output to %s\n", def_output
);
709 ret
= vpbe_set_default_output(vpbe_dev
);
711 v4l2_err(&vpbe_dev
->v4l2_dev
, "Failed to set default output %s",
716 printk(KERN_NOTICE
"Setting default mode to %s\n", def_mode
);
717 ret
= vpbe_set_default_mode(vpbe_dev
);
719 v4l2_err(&vpbe_dev
->v4l2_dev
, "Failed to set default mode %s",
723 vpbe_dev
->initialized
= 1;
724 /* TBD handling of bootargs for default output and mode */
728 mutex_lock(&vpbe_dev
->lock
);
729 kfree(vpbe_dev
->amp
);
731 kfree(vpbe_dev
->encoders
);
733 v4l2_device_unregister(&vpbe_dev
->v4l2_dev
);
735 if (strcmp(vpbe_dev
->cfg
->module_name
, "dm644x-vpbe-display") != 0) {
736 clk_disable_unprepare(vpbe_dev
->dac_clk
);
737 clk_put(vpbe_dev
->dac_clk
);
740 mutex_unlock(&vpbe_dev
->lock
);
745 * vpbe_deinitialize() - de-initialize the vpbe display controller
746 * @dev: Master and slave device ptr
747 * @vpbe_dev: vpbe device ptr
749 * vpbe_master and slave frame buffer devices calls this to de-initialize
750 * the display controller. It is called when master and slave device
751 * driver modules are removed and no longer requires the display controller.
753 static void vpbe_deinitialize(struct device
*dev
, struct vpbe_device
*vpbe_dev
)
755 v4l2_device_unregister(&vpbe_dev
->v4l2_dev
);
756 if (strcmp(vpbe_dev
->cfg
->module_name
, "dm644x-vpbe-display") != 0) {
757 clk_disable_unprepare(vpbe_dev
->dac_clk
);
758 clk_put(vpbe_dev
->dac_clk
);
761 kfree(vpbe_dev
->amp
);
762 kfree(vpbe_dev
->encoders
);
763 vpbe_dev
->initialized
= 0;
764 /* disable vpss clocks */
765 vpss_enable_clock(VPSS_VPBE_CLOCK
, 0);
768 static const struct vpbe_device_ops vpbe_dev_ops
= {
769 .enum_outputs
= vpbe_enum_outputs
,
770 .set_output
= vpbe_set_output
,
771 .get_output
= vpbe_get_output
,
772 .s_dv_timings
= vpbe_s_dv_timings
,
773 .g_dv_timings
= vpbe_g_dv_timings
,
774 .enum_dv_timings
= vpbe_enum_dv_timings
,
777 .initialize
= vpbe_initialize
,
778 .deinitialize
= vpbe_deinitialize
,
779 .get_mode_info
= vpbe_get_current_mode_info
,
780 .set_mode
= vpbe_set_mode
,
783 static int vpbe_probe(struct platform_device
*pdev
)
785 struct vpbe_device
*vpbe_dev
;
786 struct vpbe_config
*cfg
;
788 if (!pdev
->dev
.platform_data
) {
789 v4l2_err(pdev
->dev
.driver
, "No platform data\n");
792 cfg
= pdev
->dev
.platform_data
;
794 if (!cfg
->module_name
[0] ||
795 !cfg
->osd
.module_name
[0] ||
796 !cfg
->venc
.module_name
[0]) {
797 v4l2_err(pdev
->dev
.driver
, "vpbe display module names not defined\n");
801 vpbe_dev
= kzalloc(sizeof(*vpbe_dev
), GFP_KERNEL
);
806 vpbe_dev
->ops
= vpbe_dev_ops
;
807 vpbe_dev
->pdev
= &pdev
->dev
;
809 if (cfg
->outputs
->num_modes
> 0)
810 vpbe_dev
->current_timings
= vpbe_dev
->cfg
->outputs
[0].modes
[0];
816 /* set the driver data in platform device */
817 platform_set_drvdata(pdev
, vpbe_dev
);
818 mutex_init(&vpbe_dev
->lock
);
823 static int vpbe_remove(struct platform_device
*device
)
825 struct vpbe_device
*vpbe_dev
= platform_get_drvdata(device
);
832 static struct platform_driver vpbe_driver
= {
834 .name
= "vpbe_controller",
837 .remove
= vpbe_remove
,
840 module_platform_driver(vpbe_driver
);