aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/davinci
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-15 15:49:56 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-15 15:49:56 -0500
commit122804ecb59493fbb4d31b3ba9ac59faaf45276f (patch)
treecff4d8a158c412e4a8d3abc8d91bb0eb52b01c9a /drivers/media/video/davinci
parent16008d641670571ff4cd750b416c7caf2d89f467 (diff)
parent126400033940afb658123517a2e80eb68259fbd7 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (655 commits) [media] revert patch: HDIC HD29L2 DMB-TH USB2.0 reference design driver mb86a20s: Add a few more register settings at the init seq mb86a20s: Group registers into the same line [media] [PATCH] don't reset the delivery system on DTV_CLEAR [media] [BUG] it913x-fe fix typo error making SNR levels unstable [media] cx23885: Query the CX25840 during enum_input for status [media] cx25840: Add support for g_input_status [media] rc-videomate-m1f.c Rename to match remote controler name [media] drivers: media: au0828: Fix dependency for VIDEO_AU0828 [media] convert drivers/media/* to use module_platform_driver() [media] drivers: video: cx231xx: Fix dependency for VIDEO_CX231XX_DVB [media] Exynos4 JPEG codec v4l2 driver [media] doc: v4l: selection: choose pixels as units for selection rectangles [media] v4l: s5p-tv: mixer: fix setup of VP scaling [media] v4l: s5p-tv: mixer: add support for selection API [media] v4l: emulate old crop API using extended crop/compose API [media] doc: v4l: add documentation for selection API [media] doc: v4l: add binary images for selection API [media] v4l: add support for selection api [media] hd29l2: fix review findings ...
Diffstat (limited to 'drivers/media/video/davinci')
-rw-r--r--drivers/media/video/davinci/dm355_ccdc.c13
-rw-r--r--drivers/media/video/davinci/dm644x_ccdc.c13
-rw-r--r--drivers/media/video/davinci/isif.c13
-rw-r--r--drivers/media/video/davinci/vpbe.c76
-rw-r--r--drivers/media/video/davinci/vpbe_display.c43
-rw-r--r--drivers/media/video/davinci/vpbe_osd.c491
-rw-r--r--drivers/media/video/davinci/vpbe_venc.c223
-rw-r--r--drivers/media/video/davinci/vpfe_capture.c18
-rw-r--r--drivers/media/video/davinci/vpif_capture.c14
9 files changed, 679 insertions, 225 deletions
diff --git a/drivers/media/video/davinci/dm355_ccdc.c b/drivers/media/video/davinci/dm355_ccdc.c
index bd443ee76fff..f83baf3a52b0 100644
--- a/drivers/media/video/davinci/dm355_ccdc.c
+++ b/drivers/media/video/davinci/dm355_ccdc.c
@@ -1069,15 +1069,4 @@ static struct platform_driver dm355_ccdc_driver = {
1069 .probe = dm355_ccdc_probe, 1069 .probe = dm355_ccdc_probe,
1070}; 1070};
1071 1071
1072static int __init dm355_ccdc_init(void) 1072module_platform_driver(dm355_ccdc_driver);
1073{
1074 return platform_driver_register(&dm355_ccdc_driver);
1075}
1076
1077static void __exit dm355_ccdc_exit(void)
1078{
1079 platform_driver_unregister(&dm355_ccdc_driver);
1080}
1081
1082module_init(dm355_ccdc_init);
1083module_exit(dm355_ccdc_exit);
diff --git a/drivers/media/video/davinci/dm644x_ccdc.c b/drivers/media/video/davinci/dm644x_ccdc.c
index 8051c2956478..9303fe553b07 100644
--- a/drivers/media/video/davinci/dm644x_ccdc.c
+++ b/drivers/media/video/davinci/dm644x_ccdc.c
@@ -1078,15 +1078,4 @@ static struct platform_driver dm644x_ccdc_driver = {
1078 .probe = dm644x_ccdc_probe, 1078 .probe = dm644x_ccdc_probe,
1079}; 1079};
1080 1080
1081static int __init dm644x_ccdc_init(void) 1081module_platform_driver(dm644x_ccdc_driver);
1082{
1083 return platform_driver_register(&dm644x_ccdc_driver);
1084}
1085
1086static void __exit dm644x_ccdc_exit(void)
1087{
1088 platform_driver_unregister(&dm644x_ccdc_driver);
1089}
1090
1091module_init(dm644x_ccdc_init);
1092module_exit(dm644x_ccdc_exit);
diff --git a/drivers/media/video/davinci/isif.c b/drivers/media/video/davinci/isif.c
index 29c29c668596..1e63852374be 100644
--- a/drivers/media/video/davinci/isif.c
+++ b/drivers/media/video/davinci/isif.c
@@ -1156,17 +1156,6 @@ static struct platform_driver isif_driver = {
1156 .probe = isif_probe, 1156 .probe = isif_probe,
1157}; 1157};
1158 1158
1159static int __init isif_init(void) 1159module_platform_driver(isif_driver);
1160{
1161 return platform_driver_register(&isif_driver);
1162}
1163
1164static void isif_exit(void)
1165{
1166 platform_driver_unregister(&isif_driver);
1167}
1168
1169module_init(isif_init);
1170module_exit(isif_exit);
1171 1160
1172MODULE_LICENSE("GPL"); 1161MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/davinci/vpbe.c b/drivers/media/video/davinci/vpbe.c
index d773d30de221..c4a82a1a8a97 100644
--- a/drivers/media/video/davinci/vpbe.c
+++ b/drivers/media/video/davinci/vpbe.c
@@ -141,11 +141,12 @@ static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev,
141 return 0; 141 return 0;
142} 142}
143 143
144static int vpbe_get_mode_info(struct vpbe_device *vpbe_dev, char *mode) 144static int vpbe_get_mode_info(struct vpbe_device *vpbe_dev, char *mode,
145 int output_index)
145{ 146{
146 struct vpbe_config *cfg = vpbe_dev->cfg; 147 struct vpbe_config *cfg = vpbe_dev->cfg;
147 struct vpbe_enc_mode_info var; 148 struct vpbe_enc_mode_info var;
148 int curr_output = vpbe_dev->current_out_index; 149 int curr_output = output_index;
149 int i; 150 int i;
150 151
151 if (NULL == mode) 152 if (NULL == mode)
@@ -245,6 +246,8 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, int index)
245 struct encoder_config_info *curr_enc_info = 246 struct encoder_config_info *curr_enc_info =
246 vpbe_current_encoder_info(vpbe_dev); 247 vpbe_current_encoder_info(vpbe_dev);
247 struct vpbe_config *cfg = vpbe_dev->cfg; 248 struct vpbe_config *cfg = vpbe_dev->cfg;
249 struct venc_platform_data *venc_device = vpbe_dev->venc_device;
250 enum v4l2_mbus_pixelcode if_params;
248 int enc_out_index; 251 int enc_out_index;
249 int sd_index; 252 int sd_index;
250 int ret = 0; 253 int ret = 0;
@@ -274,6 +277,8 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, int index)
274 goto out; 277 goto out;
275 } 278 }
276 279
280 if_params = cfg->outputs[index].if_params;
281 venc_device->setup_if_config(if_params);
277 if (ret) 282 if (ret)
278 goto out; 283 goto out;
279 } 284 }
@@ -293,7 +298,7 @@ static int vpbe_set_output(struct vpbe_device *vpbe_dev, int index)
293 * encoder. 298 * encoder.
294 */ 299 */
295 ret = vpbe_get_mode_info(vpbe_dev, 300 ret = vpbe_get_mode_info(vpbe_dev,
296 cfg->outputs[index].default_mode); 301 cfg->outputs[index].default_mode, index);
297 if (!ret) { 302 if (!ret) {
298 struct osd_state *osd_device = vpbe_dev->osd_device; 303 struct osd_state *osd_device = vpbe_dev->osd_device;
299 304
@@ -367,6 +372,11 @@ static int vpbe_s_dv_preset(struct vpbe_device *vpbe_dev,
367 372
368 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video, 373 ret = v4l2_subdev_call(vpbe_dev->encoders[sd_index], video,
369 s_dv_preset, dv_preset); 374 s_dv_preset, dv_preset);
375 if (!ret && (vpbe_dev->amp != NULL)) {
376 /* Call amplifier subdevice */
377 ret = v4l2_subdev_call(vpbe_dev->amp, video,
378 s_dv_preset, dv_preset);
379 }
370 /* set the lcd controller output for the given mode */ 380 /* set the lcd controller output for the given mode */
371 if (!ret) { 381 if (!ret) {
372 struct osd_state *osd_device = vpbe_dev->osd_device; 382 struct osd_state *osd_device = vpbe_dev->osd_device;
@@ -566,6 +576,8 @@ static int platform_device_get(struct device *dev, void *data)
566 576
567 if (strcmp("vpbe-osd", pdev->name) == 0) 577 if (strcmp("vpbe-osd", pdev->name) == 0)
568 vpbe_dev->osd_device = platform_get_drvdata(pdev); 578 vpbe_dev->osd_device = platform_get_drvdata(pdev);
579 if (strcmp("vpbe-venc", pdev->name) == 0)
580 vpbe_dev->venc_device = dev_get_platdata(&pdev->dev);
569 581
570 return 0; 582 return 0;
571} 583}
@@ -584,6 +596,7 @@ static int platform_device_get(struct device *dev, void *data)
584static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev) 596static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
585{ 597{
586 struct encoder_config_info *enc_info; 598 struct encoder_config_info *enc_info;
599 struct amp_config_info *amp_info;
587 struct v4l2_subdev **enc_subdev; 600 struct v4l2_subdev **enc_subdev;
588 struct osd_state *osd_device; 601 struct osd_state *osd_device;
589 struct i2c_adapter *i2c_adap; 602 struct i2c_adapter *i2c_adap;
@@ -704,6 +717,32 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
704 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c encoders" 717 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c encoders"
705 " currently not supported"); 718 " currently not supported");
706 } 719 }
720 /* Add amplifier subdevice for dm365 */
721 if ((strcmp(vpbe_dev->cfg->module_name, "dm365-vpbe-display") == 0) &&
722 vpbe_dev->cfg->amp != NULL) {
723 amp_info = vpbe_dev->cfg->amp;
724 if (amp_info->is_i2c) {
725 vpbe_dev->amp = v4l2_i2c_new_subdev_board(
726 &vpbe_dev->v4l2_dev, i2c_adap,
727 &amp_info->board_info, NULL);
728 if (!vpbe_dev->amp) {
729 v4l2_err(&vpbe_dev->v4l2_dev,
730 "amplifier %s failed to register",
731 amp_info->module_name);
732 ret = -ENODEV;
733 goto vpbe_fail_amp_register;
734 }
735 v4l2_info(&vpbe_dev->v4l2_dev,
736 "v4l2 sub device %s registered\n",
737 amp_info->module_name);
738 } else {
739 vpbe_dev->amp = NULL;
740 v4l2_warn(&vpbe_dev->v4l2_dev, "non-i2c amplifiers"
741 " currently not supported");
742 }
743 } else {
744 vpbe_dev->amp = NULL;
745 }
707 746
708 /* set the current encoder and output to that of venc by default */ 747 /* set the current encoder and output to that of venc by default */
709 vpbe_dev->current_sd_index = 0; 748 vpbe_dev->current_sd_index = 0;
@@ -731,6 +770,8 @@ static int vpbe_initialize(struct device *dev, struct vpbe_device *vpbe_dev)
731 /* TBD handling of bootargs for default output and mode */ 770 /* TBD handling of bootargs for default output and mode */
732 return 0; 771 return 0;
733 772
773vpbe_fail_amp_register:
774 kfree(vpbe_dev->amp);
734vpbe_fail_sd_register: 775vpbe_fail_sd_register:
735 kfree(vpbe_dev->encoders); 776 kfree(vpbe_dev->encoders);
736vpbe_fail_v4l2_device: 777vpbe_fail_v4l2_device:
@@ -757,6 +798,7 @@ static void vpbe_deinitialize(struct device *dev, struct vpbe_device *vpbe_dev)
757 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0) 798 if (strcmp(vpbe_dev->cfg->module_name, "dm644x-vpbe-display") != 0)
758 clk_put(vpbe_dev->dac_clk); 799 clk_put(vpbe_dev->dac_clk);
759 800
801 kfree(vpbe_dev->amp);
760 kfree(vpbe_dev->encoders); 802 kfree(vpbe_dev->encoders);
761 vpbe_dev->initialized = 0; 803 vpbe_dev->initialized = 0;
762 /* disable vpss clocks */ 804 /* disable vpss clocks */
@@ -811,8 +853,10 @@ static __devinit int vpbe_probe(struct platform_device *pdev)
811 853
812 if (cfg->outputs->num_modes > 0) 854 if (cfg->outputs->num_modes > 0)
813 vpbe_dev->current_timings = vpbe_dev->cfg->outputs[0].modes[0]; 855 vpbe_dev->current_timings = vpbe_dev->cfg->outputs[0].modes[0];
814 else 856 else {
857 kfree(vpbe_dev);
815 return -ENODEV; 858 return -ENODEV;
859 }
816 860
817 /* set the driver data in platform device */ 861 /* set the driver data in platform device */
818 platform_set_drvdata(pdev, vpbe_dev); 862 platform_set_drvdata(pdev, vpbe_dev);
@@ -839,26 +883,4 @@ static struct platform_driver vpbe_driver = {
839 .remove = vpbe_remove, 883 .remove = vpbe_remove,
840}; 884};
841 885
842/** 886module_platform_driver(vpbe_driver);
843 * vpbe_init: initialize the vpbe driver
844 *
845 * This function registers device and driver to the kernel
846 */
847static __init int vpbe_init(void)
848{
849 return platform_driver_register(&vpbe_driver);
850}
851
852/**
853 * vpbe_cleanup : cleanup function for vpbe driver
854 *
855 * This will un-registers the device and driver to the kernel
856 */
857static void vpbe_cleanup(void)
858{
859 platform_driver_unregister(&vpbe_driver);
860}
861
862/* Function for module initialization and cleanup */
863module_init(vpbe_init);
864module_exit(vpbe_cleanup);
diff --git a/drivers/media/video/davinci/vpbe_display.c b/drivers/media/video/davinci/vpbe_display.c
index 8588a86d9b45..1f3b1c729252 100644
--- a/drivers/media/video/davinci/vpbe_display.c
+++ b/drivers/media/video/davinci/vpbe_display.c
@@ -1746,15 +1746,16 @@ static __devinit int vpbe_display_probe(struct platform_device *pdev)
1746 for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) { 1746 for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {
1747 if (register_device(disp_dev->dev[i], disp_dev, pdev)) { 1747 if (register_device(disp_dev->dev[i], disp_dev, pdev)) {
1748 err = -ENODEV; 1748 err = -ENODEV;
1749 goto probe_out; 1749 goto probe_out_irq;
1750 } 1750 }
1751 } 1751 }
1752 1752
1753 printk(KERN_DEBUG "Successfully completed the probing of vpbe v4l2 device\n"); 1753 printk(KERN_DEBUG "Successfully completed the probing of vpbe v4l2 device\n");
1754 return 0; 1754 return 0;
1755 1755
1756probe_out: 1756probe_out_irq:
1757 free_irq(res->start, disp_dev); 1757 free_irq(res->start, disp_dev);
1758probe_out:
1758 for (k = 0; k < VPBE_DISPLAY_MAX_DEVICES; k++) { 1759 for (k = 0; k < VPBE_DISPLAY_MAX_DEVICES; k++) {
1759 /* Get the pointer to the layer object */ 1760 /* Get the pointer to the layer object */
1760 vpbe_display_layer = disp_dev->dev[k]; 1761 vpbe_display_layer = disp_dev->dev[k];
@@ -1816,43 +1817,7 @@ static struct platform_driver vpbe_display_driver = {
1816 .remove = __devexit_p(vpbe_display_remove), 1817 .remove = __devexit_p(vpbe_display_remove),
1817}; 1818};
1818 1819
1819/* 1820module_platform_driver(vpbe_display_driver);
1820 * vpbe_display_init()
1821 * This function registers device and driver to the kernel, requests irq
1822 * handler and allocates memory for layer objects
1823 */
1824static __devinit int vpbe_display_init(void)
1825{
1826 int err;
1827
1828 printk(KERN_DEBUG "vpbe_display_init\n");
1829
1830 /* Register driver to the kernel */
1831 err = platform_driver_register(&vpbe_display_driver);
1832 if (0 != err)
1833 return err;
1834
1835 printk(KERN_DEBUG "vpbe_display_init:"
1836 "VPBE V4L2 Display Driver V1.0 loaded\n");
1837 return 0;
1838}
1839
1840/*
1841 * vpbe_display_cleanup()
1842 * This function un-registers device and driver to the kernel, frees requested
1843 * irq handler and de-allocates memory allocated for layer objects.
1844 */
1845static void vpbe_display_cleanup(void)
1846{
1847 printk(KERN_DEBUG "vpbe_display_cleanup\n");
1848
1849 /* platform driver unregister */
1850 platform_driver_unregister(&vpbe_display_driver);
1851}
1852
1853/* Function for module initialization and cleanup */
1854module_init(vpbe_display_init);
1855module_exit(vpbe_display_cleanup);
1856 1821
1857MODULE_DESCRIPTION("TI DM644x/DM355/DM365 VPBE Display controller"); 1822MODULE_DESCRIPTION("TI DM644x/DM355/DM365 VPBE Display controller");
1858MODULE_LICENSE("GPL"); 1823MODULE_LICENSE("GPL");
diff --git a/drivers/media/video/davinci/vpbe_osd.c b/drivers/media/video/davinci/vpbe_osd.c
index ceccf4302518..d6488b79ae3b 100644
--- a/drivers/media/video/davinci/vpbe_osd.c
+++ b/drivers/media/video/davinci/vpbe_osd.c
@@ -248,11 +248,29 @@ static void _osd_set_rec601_attenuation(struct osd_state *sd,
248 osd_modify(sd, OSD_OSDWIN0MD_ATN0E, 248 osd_modify(sd, OSD_OSDWIN0MD_ATN0E,
249 enable ? OSD_OSDWIN0MD_ATN0E : 0, 249 enable ? OSD_OSDWIN0MD_ATN0E : 0,
250 OSD_OSDWIN0MD); 250 OSD_OSDWIN0MD);
251 if (sd->vpbe_type == VPBE_VERSION_1)
252 osd_modify(sd, OSD_OSDWIN0MD_ATN0E,
253 enable ? OSD_OSDWIN0MD_ATN0E : 0,
254 OSD_OSDWIN0MD);
255 else if ((sd->vpbe_type == VPBE_VERSION_3) ||
256 (sd->vpbe_type == VPBE_VERSION_2))
257 osd_modify(sd, OSD_EXTMODE_ATNOSD0EN,
258 enable ? OSD_EXTMODE_ATNOSD0EN : 0,
259 OSD_EXTMODE);
251 break; 260 break;
252 case OSDWIN_OSD1: 261 case OSDWIN_OSD1:
253 osd_modify(sd, OSD_OSDWIN1MD_ATN1E, 262 osd_modify(sd, OSD_OSDWIN1MD_ATN1E,
254 enable ? OSD_OSDWIN1MD_ATN1E : 0, 263 enable ? OSD_OSDWIN1MD_ATN1E : 0,
255 OSD_OSDWIN1MD); 264 OSD_OSDWIN1MD);
265 if (sd->vpbe_type == VPBE_VERSION_1)
266 osd_modify(sd, OSD_OSDWIN1MD_ATN1E,
267 enable ? OSD_OSDWIN1MD_ATN1E : 0,
268 OSD_OSDWIN1MD);
269 else if ((sd->vpbe_type == VPBE_VERSION_3) ||
270 (sd->vpbe_type == VPBE_VERSION_2))
271 osd_modify(sd, OSD_EXTMODE_ATNOSD1EN,
272 enable ? OSD_EXTMODE_ATNOSD1EN : 0,
273 OSD_EXTMODE);
256 break; 274 break;
257 } 275 }
258} 276}
@@ -273,15 +291,71 @@ static void _osd_set_blending_factor(struct osd_state *sd,
273 } 291 }
274} 292}
275 293
294static void _osd_enable_rgb888_pixblend(struct osd_state *sd,
295 enum osd_win_layer osdwin)
296{
297
298 osd_modify(sd, OSD_MISCCTL_BLDSEL, 0, OSD_MISCCTL);
299 switch (osdwin) {
300 case OSDWIN_OSD0:
301 osd_modify(sd, OSD_EXTMODE_OSD0BLDCHR,
302 OSD_EXTMODE_OSD0BLDCHR, OSD_EXTMODE);
303 break;
304 case OSDWIN_OSD1:
305 osd_modify(sd, OSD_EXTMODE_OSD1BLDCHR,
306 OSD_EXTMODE_OSD1BLDCHR, OSD_EXTMODE);
307 break;
308 }
309}
310
276static void _osd_enable_color_key(struct osd_state *sd, 311static void _osd_enable_color_key(struct osd_state *sd,
277 enum osd_win_layer osdwin, 312 enum osd_win_layer osdwin,
278 unsigned colorkey, 313 unsigned colorkey,
279 enum osd_pix_format pixfmt) 314 enum osd_pix_format pixfmt)
280{ 315{
281 switch (pixfmt) { 316 switch (pixfmt) {
317 case PIXFMT_1BPP:
318 case PIXFMT_2BPP:
319 case PIXFMT_4BPP:
320 case PIXFMT_8BPP:
321 if (sd->vpbe_type == VPBE_VERSION_3) {
322 switch (osdwin) {
323 case OSDWIN_OSD0:
324 osd_modify(sd, OSD_TRANSPBMPIDX_BMP0,
325 colorkey <<
326 OSD_TRANSPBMPIDX_BMP0_SHIFT,
327 OSD_TRANSPBMPIDX);
328 break;
329 case OSDWIN_OSD1:
330 osd_modify(sd, OSD_TRANSPBMPIDX_BMP1,
331 colorkey <<
332 OSD_TRANSPBMPIDX_BMP1_SHIFT,
333 OSD_TRANSPBMPIDX);
334 break;
335 }
336 }
337 break;
282 case PIXFMT_RGB565: 338 case PIXFMT_RGB565:
283 osd_write(sd, colorkey & OSD_TRANSPVAL_RGBTRANS, 339 if (sd->vpbe_type == VPBE_VERSION_1)
284 OSD_TRANSPVAL); 340 osd_write(sd, colorkey & OSD_TRANSPVAL_RGBTRANS,
341 OSD_TRANSPVAL);
342 else if (sd->vpbe_type == VPBE_VERSION_3)
343 osd_write(sd, colorkey & OSD_TRANSPVALL_RGBL,
344 OSD_TRANSPVALL);
345 break;
346 case PIXFMT_YCbCrI:
347 case PIXFMT_YCrCbI:
348 if (sd->vpbe_type == VPBE_VERSION_3)
349 osd_modify(sd, OSD_TRANSPVALU_Y, colorkey,
350 OSD_TRANSPVALU);
351 break;
352 case PIXFMT_RGB888:
353 if (sd->vpbe_type == VPBE_VERSION_3) {
354 osd_write(sd, colorkey & OSD_TRANSPVALL_RGBL,
355 OSD_TRANSPVALL);
356 osd_modify(sd, OSD_TRANSPVALU_RGBU, colorkey >> 16,
357 OSD_TRANSPVALU);
358 }
285 break; 359 break;
286 default: 360 default:
287 break; 361 break;
@@ -470,23 +544,188 @@ static int osd_enable_layer(struct osd_state *sd, enum osd_layer layer,
470 return 0; 544 return 0;
471} 545}
472 546
547#define OSD_SRC_ADDR_HIGH4 0x7800000
548#define OSD_SRC_ADDR_HIGH7 0x7F0000
549#define OSD_SRCADD_OFSET_SFT 23
550#define OSD_SRCADD_ADD_SFT 16
551#define OSD_WINADL_MASK 0xFFFF
552#define OSD_WINOFST_MASK 0x1000
553#define VPBE_REG_BASE 0x80000000
554
473static void _osd_start_layer(struct osd_state *sd, enum osd_layer layer, 555static void _osd_start_layer(struct osd_state *sd, enum osd_layer layer,
474 unsigned long fb_base_phys, 556 unsigned long fb_base_phys,
475 unsigned long cbcr_ofst) 557 unsigned long cbcr_ofst)
476{ 558{
477 switch (layer) { 559
478 case WIN_OSD0: 560 if (sd->vpbe_type == VPBE_VERSION_1) {
479 osd_write(sd, fb_base_phys & ~0x1F, OSD_OSDWIN0ADR); 561 switch (layer) {
480 break; 562 case WIN_OSD0:
481 case WIN_VID0: 563 osd_write(sd, fb_base_phys & ~0x1F, OSD_OSDWIN0ADR);
482 osd_write(sd, fb_base_phys & ~0x1F, OSD_VIDWIN0ADR); 564 break;
483 break; 565 case WIN_VID0:
484 case WIN_OSD1: 566 osd_write(sd, fb_base_phys & ~0x1F, OSD_VIDWIN0ADR);
485 osd_write(sd, fb_base_phys & ~0x1F, OSD_OSDWIN1ADR); 567 break;
486 break; 568 case WIN_OSD1:
487 case WIN_VID1: 569 osd_write(sd, fb_base_phys & ~0x1F, OSD_OSDWIN1ADR);
488 osd_write(sd, fb_base_phys & ~0x1F, OSD_VIDWIN1ADR); 570 break;
489 break; 571 case WIN_VID1:
572 osd_write(sd, fb_base_phys & ~0x1F, OSD_VIDWIN1ADR);
573 break;
574 }
575 } else if (sd->vpbe_type == VPBE_VERSION_3) {
576 unsigned long fb_offset_32 =
577 (fb_base_phys - VPBE_REG_BASE) >> 5;
578
579 switch (layer) {
580 case WIN_OSD0:
581 osd_modify(sd, OSD_OSDWINADH_O0AH,
582 fb_offset_32 >> (OSD_SRCADD_ADD_SFT -
583 OSD_OSDWINADH_O0AH_SHIFT),
584 OSD_OSDWINADH);
585 osd_write(sd, fb_offset_32 & OSD_OSDWIN0ADL_O0AL,
586 OSD_OSDWIN0ADL);
587 break;
588 case WIN_VID0:
589 osd_modify(sd, OSD_VIDWINADH_V0AH,
590 fb_offset_32 >> (OSD_SRCADD_ADD_SFT -
591 OSD_VIDWINADH_V0AH_SHIFT),
592 OSD_VIDWINADH);
593 osd_write(sd, fb_offset_32 & OSD_VIDWIN0ADL_V0AL,
594 OSD_VIDWIN0ADL);
595 break;
596 case WIN_OSD1:
597 osd_modify(sd, OSD_OSDWINADH_O1AH,
598 fb_offset_32 >> (OSD_SRCADD_ADD_SFT -
599 OSD_OSDWINADH_O1AH_SHIFT),
600 OSD_OSDWINADH);
601 osd_write(sd, fb_offset_32 & OSD_OSDWIN1ADL_O1AL,
602 OSD_OSDWIN1ADL);
603 break;
604 case WIN_VID1:
605 osd_modify(sd, OSD_VIDWINADH_V1AH,
606 fb_offset_32 >> (OSD_SRCADD_ADD_SFT -
607 OSD_VIDWINADH_V1AH_SHIFT),
608 OSD_VIDWINADH);
609 osd_write(sd, fb_offset_32 & OSD_VIDWIN1ADL_V1AL,
610 OSD_VIDWIN1ADL);
611 break;
612 }
613 } else if (sd->vpbe_type == VPBE_VERSION_2) {
614 struct osd_window_state *win = &sd->win[layer];
615 unsigned long fb_offset_32, cbcr_offset_32;
616
617 fb_offset_32 = fb_base_phys - VPBE_REG_BASE;
618 if (cbcr_ofst)
619 cbcr_offset_32 = cbcr_ofst;
620 else
621 cbcr_offset_32 = win->lconfig.line_length *
622 win->lconfig.ysize;
623 cbcr_offset_32 += fb_offset_32;
624 fb_offset_32 = fb_offset_32 >> 5;
625 cbcr_offset_32 = cbcr_offset_32 >> 5;
626 /*
627 * DM365: start address is 27-bit long address b26 - b23 are
628 * in offset register b12 - b9, and * bit 26 has to be '1'
629 */
630 if (win->lconfig.pixfmt == PIXFMT_NV12) {
631 switch (layer) {
632 case WIN_VID0:
633 case WIN_VID1:
634 /* Y is in VID0 */
635 osd_modify(sd, OSD_VIDWIN0OFST_V0AH,
636 ((fb_offset_32 & OSD_SRC_ADDR_HIGH4) >>
637 (OSD_SRCADD_OFSET_SFT -
638 OSD_WINOFST_AH_SHIFT)) |
639 OSD_WINOFST_MASK, OSD_VIDWIN0OFST);
640 osd_modify(sd, OSD_VIDWINADH_V0AH,
641 (fb_offset_32 & OSD_SRC_ADDR_HIGH7) >>
642 (OSD_SRCADD_ADD_SFT -
643 OSD_VIDWINADH_V0AH_SHIFT),
644 OSD_VIDWINADH);
645 osd_write(sd, fb_offset_32 & OSD_WINADL_MASK,
646 OSD_VIDWIN0ADL);
647 /* CbCr is in VID1 */
648 osd_modify(sd, OSD_VIDWIN1OFST_V1AH,
649 ((cbcr_offset_32 &
650 OSD_SRC_ADDR_HIGH4) >>
651 (OSD_SRCADD_OFSET_SFT -
652 OSD_WINOFST_AH_SHIFT)) |
653 OSD_WINOFST_MASK, OSD_VIDWIN1OFST);
654 osd_modify(sd, OSD_VIDWINADH_V1AH,
655 (cbcr_offset_32 &
656 OSD_SRC_ADDR_HIGH7) >>
657 (OSD_SRCADD_ADD_SFT -
658 OSD_VIDWINADH_V1AH_SHIFT),
659 OSD_VIDWINADH);
660 osd_write(sd, cbcr_offset_32 & OSD_WINADL_MASK,
661 OSD_VIDWIN1ADL);
662 break;
663 default:
664 break;
665 }
666 }
667
668 switch (layer) {
669 case WIN_OSD0:
670 osd_modify(sd, OSD_OSDWIN0OFST_O0AH,
671 ((fb_offset_32 & OSD_SRC_ADDR_HIGH4) >>
672 (OSD_SRCADD_OFSET_SFT -
673 OSD_WINOFST_AH_SHIFT)) | OSD_WINOFST_MASK,
674 OSD_OSDWIN0OFST);
675 osd_modify(sd, OSD_OSDWINADH_O0AH,
676 (fb_offset_32 & OSD_SRC_ADDR_HIGH7) >>
677 (OSD_SRCADD_ADD_SFT -
678 OSD_OSDWINADH_O0AH_SHIFT), OSD_OSDWINADH);
679 osd_write(sd, fb_offset_32 & OSD_WINADL_MASK,
680 OSD_OSDWIN0ADL);
681 break;
682 case WIN_VID0:
683 if (win->lconfig.pixfmt != PIXFMT_NV12) {
684 osd_modify(sd, OSD_VIDWIN0OFST_V0AH,
685 ((fb_offset_32 & OSD_SRC_ADDR_HIGH4) >>
686 (OSD_SRCADD_OFSET_SFT -
687 OSD_WINOFST_AH_SHIFT)) |
688 OSD_WINOFST_MASK, OSD_VIDWIN0OFST);
689 osd_modify(sd, OSD_VIDWINADH_V0AH,
690 (fb_offset_32 & OSD_SRC_ADDR_HIGH7) >>
691 (OSD_SRCADD_ADD_SFT -
692 OSD_VIDWINADH_V0AH_SHIFT),
693 OSD_VIDWINADH);
694 osd_write(sd, fb_offset_32 & OSD_WINADL_MASK,
695 OSD_VIDWIN0ADL);
696 }
697 break;
698 case WIN_OSD1:
699 osd_modify(sd, OSD_OSDWIN1OFST_O1AH,
700 ((fb_offset_32 & OSD_SRC_ADDR_HIGH4) >>
701 (OSD_SRCADD_OFSET_SFT -
702 OSD_WINOFST_AH_SHIFT)) | OSD_WINOFST_MASK,
703 OSD_OSDWIN1OFST);
704 osd_modify(sd, OSD_OSDWINADH_O1AH,
705 (fb_offset_32 & OSD_SRC_ADDR_HIGH7) >>
706 (OSD_SRCADD_ADD_SFT -
707 OSD_OSDWINADH_O1AH_SHIFT),
708 OSD_OSDWINADH);
709 osd_write(sd, fb_offset_32 & OSD_WINADL_MASK,
710 OSD_OSDWIN1ADL);
711 break;
712 case WIN_VID1:
713 if (win->lconfig.pixfmt != PIXFMT_NV12) {
714 osd_modify(sd, OSD_VIDWIN1OFST_V1AH,
715 ((fb_offset_32 & OSD_SRC_ADDR_HIGH4) >>
716 (OSD_SRCADD_OFSET_SFT -
717 OSD_WINOFST_AH_SHIFT)) |
718 OSD_WINOFST_MASK, OSD_VIDWIN1OFST);
719 osd_modify(sd, OSD_VIDWINADH_V1AH,
720 (fb_offset_32 & OSD_SRC_ADDR_HIGH7) >>
721 (OSD_SRCADD_ADD_SFT -
722 OSD_VIDWINADH_V1AH_SHIFT),
723 OSD_VIDWINADH);
724 osd_write(sd, fb_offset_32 & OSD_WINADL_MASK,
725 OSD_VIDWIN1ADL);
726 }
727 break;
728 }
490 } 729 }
491} 730}
492 731
@@ -545,7 +784,7 @@ static int try_layer_config(struct osd_state *sd, enum osd_layer layer,
545{ 784{
546 struct osd_state *osd = sd; 785 struct osd_state *osd = sd;
547 struct osd_window_state *win = &osd->win[layer]; 786 struct osd_window_state *win = &osd->win[layer];
548 int bad_config; 787 int bad_config = 0;
549 788
550 /* verify that the pixel format is compatible with the layer */ 789 /* verify that the pixel format is compatible with the layer */
551 switch (lconfig->pixfmt) { 790 switch (lconfig->pixfmt) {
@@ -554,17 +793,25 @@ static int try_layer_config(struct osd_state *sd, enum osd_layer layer,
554 case PIXFMT_4BPP: 793 case PIXFMT_4BPP:
555 case PIXFMT_8BPP: 794 case PIXFMT_8BPP:
556 case PIXFMT_RGB565: 795 case PIXFMT_RGB565:
557 bad_config = !is_osd_win(layer); 796 if (osd->vpbe_type == VPBE_VERSION_1)
797 bad_config = !is_vid_win(layer);
558 break; 798 break;
559 case PIXFMT_YCbCrI: 799 case PIXFMT_YCbCrI:
560 case PIXFMT_YCrCbI: 800 case PIXFMT_YCrCbI:
561 bad_config = !is_vid_win(layer); 801 bad_config = !is_vid_win(layer);
562 break; 802 break;
563 case PIXFMT_RGB888: 803 case PIXFMT_RGB888:
564 bad_config = !is_vid_win(layer); 804 if (osd->vpbe_type == VPBE_VERSION_1)
805 bad_config = !is_vid_win(layer);
806 else if ((osd->vpbe_type == VPBE_VERSION_3) ||
807 (osd->vpbe_type == VPBE_VERSION_2))
808 bad_config = !is_osd_win(layer);
565 break; 809 break;
566 case PIXFMT_NV12: 810 case PIXFMT_NV12:
567 bad_config = 1; 811 if (osd->vpbe_type != VPBE_VERSION_2)
812 bad_config = 1;
813 else
814 bad_config = is_osd_win(layer);
568 break; 815 break;
569 case PIXFMT_OSD_ATTR: 816 case PIXFMT_OSD_ATTR:
570 bad_config = (layer != WIN_OSD1); 817 bad_config = (layer != WIN_OSD1);
@@ -584,7 +831,8 @@ static int try_layer_config(struct osd_state *sd, enum osd_layer layer,
584 831
585 /* DM6446: */ 832 /* DM6446: */
586 /* only one OSD window at a time can use RGB pixel formats */ 833 /* only one OSD window at a time can use RGB pixel formats */
587 if (is_osd_win(layer) && is_rgb_pixfmt(lconfig->pixfmt)) { 834 if ((osd->vpbe_type == VPBE_VERSION_1) &&
835 is_osd_win(layer) && is_rgb_pixfmt(lconfig->pixfmt)) {
588 enum osd_pix_format pixfmt; 836 enum osd_pix_format pixfmt;
589 if (layer == WIN_OSD0) 837 if (layer == WIN_OSD0)
590 pixfmt = osd->win[WIN_OSD1].lconfig.pixfmt; 838 pixfmt = osd->win[WIN_OSD1].lconfig.pixfmt;
@@ -602,7 +850,8 @@ static int try_layer_config(struct osd_state *sd, enum osd_layer layer,
602 } 850 }
603 851
604 /* DM6446: only one video window at a time can use RGB888 */ 852 /* DM6446: only one video window at a time can use RGB888 */
605 if (is_vid_win(layer) && lconfig->pixfmt == PIXFMT_RGB888) { 853 if ((osd->vpbe_type == VPBE_VERSION_1) && is_vid_win(layer) &&
854 lconfig->pixfmt == PIXFMT_RGB888) {
606 enum osd_pix_format pixfmt; 855 enum osd_pix_format pixfmt;
607 856
608 if (layer == WIN_VID0) 857 if (layer == WIN_VID0)
@@ -652,7 +901,8 @@ static void _osd_disable_vid_rgb888(struct osd_state *sd)
652 * The caller must ensure that neither video window is currently 901 * The caller must ensure that neither video window is currently
653 * configured for RGB888 pixel format. 902 * configured for RGB888 pixel format.
654 */ 903 */
655 osd_clear(sd, OSD_MISCCTL_RGBEN, OSD_MISCCTL); 904 if (sd->vpbe_type == VPBE_VERSION_1)
905 osd_clear(sd, OSD_MISCCTL_RGBEN, OSD_MISCCTL);
656} 906}
657 907
658static void _osd_enable_vid_rgb888(struct osd_state *sd, 908static void _osd_enable_vid_rgb888(struct osd_state *sd,
@@ -665,13 +915,14 @@ static void _osd_enable_vid_rgb888(struct osd_state *sd,
665 * currently configured for RGB888 pixel format, as this routine will 915 * currently configured for RGB888 pixel format, as this routine will
666 * disable RGB888 pixel format for the other window. 916 * disable RGB888 pixel format for the other window.
667 */ 917 */
668 if (layer == WIN_VID0) { 918 if (sd->vpbe_type == VPBE_VERSION_1) {
669 osd_modify(sd, OSD_MISCCTL_RGBEN | OSD_MISCCTL_RGBWIN, 919 if (layer == WIN_VID0)
670 OSD_MISCCTL_RGBEN, OSD_MISCCTL); 920 osd_modify(sd, OSD_MISCCTL_RGBEN | OSD_MISCCTL_RGBWIN,
671 } else if (layer == WIN_VID1) { 921 OSD_MISCCTL_RGBEN, OSD_MISCCTL);
672 osd_modify(sd, OSD_MISCCTL_RGBEN | OSD_MISCCTL_RGBWIN, 922 else if (layer == WIN_VID1)
673 OSD_MISCCTL_RGBEN | OSD_MISCCTL_RGBWIN, 923 osd_modify(sd, OSD_MISCCTL_RGBEN | OSD_MISCCTL_RGBWIN,
674 OSD_MISCCTL); 924 OSD_MISCCTL_RGBEN | OSD_MISCCTL_RGBWIN,
925 OSD_MISCCTL);
675 } 926 }
676} 927}
677 928
@@ -697,9 +948,30 @@ static void _osd_set_layer_config(struct osd_state *sd, enum osd_layer layer,
697 948
698 switch (layer) { 949 switch (layer) {
699 case WIN_OSD0: 950 case WIN_OSD0:
700 winmd_mask |= OSD_OSDWIN0MD_RGB0E; 951 if (sd->vpbe_type == VPBE_VERSION_1) {
701 if (lconfig->pixfmt == PIXFMT_RGB565) 952 winmd_mask |= OSD_OSDWIN0MD_RGB0E;
702 winmd |= OSD_OSDWIN0MD_RGB0E; 953 if (lconfig->pixfmt == PIXFMT_RGB565)
954 winmd |= OSD_OSDWIN0MD_RGB0E;
955 } else if ((sd->vpbe_type == VPBE_VERSION_3) ||
956 (sd->vpbe_type == VPBE_VERSION_2)) {
957 winmd_mask |= OSD_OSDWIN0MD_BMP0MD;
958 switch (lconfig->pixfmt) {
959 case PIXFMT_RGB565:
960 winmd |= (1 <<
961 OSD_OSDWIN0MD_BMP0MD_SHIFT);
962 break;
963 case PIXFMT_RGB888:
964 winmd |= (2 << OSD_OSDWIN0MD_BMP0MD_SHIFT);
965 _osd_enable_rgb888_pixblend(sd, OSDWIN_OSD0);
966 break;
967 case PIXFMT_YCbCrI:
968 case PIXFMT_YCrCbI:
969 winmd |= (3 << OSD_OSDWIN0MD_BMP0MD_SHIFT);
970 break;
971 default:
972 break;
973 }
974 }
703 975
704 winmd_mask |= OSD_OSDWIN0MD_BMW0 | OSD_OSDWIN0MD_OFF0; 976 winmd_mask |= OSD_OSDWIN0MD_BMW0 | OSD_OSDWIN0MD_OFF0;
705 977
@@ -749,12 +1021,59 @@ static void _osd_set_layer_config(struct osd_state *sd, enum osd_layer layer,
749 * For YUV420P format the register contents are 1021 * For YUV420P format the register contents are
750 * duplicated in both VID registers 1022 * duplicated in both VID registers
751 */ 1023 */
1024 if ((sd->vpbe_type == VPBE_VERSION_2) &&
1025 (lconfig->pixfmt == PIXFMT_NV12)) {
1026 /* other window also */
1027 if (lconfig->interlaced) {
1028 winmd_mask |= OSD_VIDWINMD_VFF1;
1029 winmd |= OSD_VIDWINMD_VFF1;
1030 osd_modify(sd, winmd_mask, winmd,
1031 OSD_VIDWINMD);
1032 }
1033
1034 osd_modify(sd, OSD_MISCCTL_S420D,
1035 OSD_MISCCTL_S420D, OSD_MISCCTL);
1036 osd_write(sd, lconfig->line_length >> 5,
1037 OSD_VIDWIN1OFST);
1038 osd_write(sd, lconfig->xpos, OSD_VIDWIN1XP);
1039 osd_write(sd, lconfig->xsize, OSD_VIDWIN1XL);
1040 /*
1041 * if NV21 pixfmt and line length not 32B
1042 * aligned (e.g. NTSC), Need to set window
1043 * X pixel size to be 32B aligned as well
1044 */
1045 if (lconfig->xsize % 32) {
1046 osd_write(sd,
1047 ((lconfig->xsize + 31) & ~31),
1048 OSD_VIDWIN1XL);
1049 osd_write(sd,
1050 ((lconfig->xsize + 31) & ~31),
1051 OSD_VIDWIN0XL);
1052 }
1053 } else if ((sd->vpbe_type == VPBE_VERSION_2) &&
1054 (lconfig->pixfmt != PIXFMT_NV12)) {
1055 osd_modify(sd, OSD_MISCCTL_S420D, ~OSD_MISCCTL_S420D,
1056 OSD_MISCCTL);
1057 }
1058
752 if (lconfig->interlaced) { 1059 if (lconfig->interlaced) {
753 osd_write(sd, lconfig->ypos >> 1, OSD_VIDWIN0YP); 1060 osd_write(sd, lconfig->ypos >> 1, OSD_VIDWIN0YP);
754 osd_write(sd, lconfig->ysize >> 1, OSD_VIDWIN0YL); 1061 osd_write(sd, lconfig->ysize >> 1, OSD_VIDWIN0YL);
1062 if ((sd->vpbe_type == VPBE_VERSION_2) &&
1063 lconfig->pixfmt == PIXFMT_NV12) {
1064 osd_write(sd, lconfig->ypos >> 1,
1065 OSD_VIDWIN1YP);
1066 osd_write(sd, lconfig->ysize >> 1,
1067 OSD_VIDWIN1YL);
1068 }
755 } else { 1069 } else {
756 osd_write(sd, lconfig->ypos, OSD_VIDWIN0YP); 1070 osd_write(sd, lconfig->ypos, OSD_VIDWIN0YP);
757 osd_write(sd, lconfig->ysize, OSD_VIDWIN0YL); 1071 osd_write(sd, lconfig->ysize, OSD_VIDWIN0YL);
1072 if ((sd->vpbe_type == VPBE_VERSION_2) &&
1073 lconfig->pixfmt == PIXFMT_NV12) {
1074 osd_write(sd, lconfig->ypos, OSD_VIDWIN1YP);
1075 osd_write(sd, lconfig->ysize, OSD_VIDWIN1YL);
1076 }
758 } 1077 }
759 break; 1078 break;
760 case WIN_OSD1: 1079 case WIN_OSD1:
@@ -764,14 +1083,43 @@ static void _osd_set_layer_config(struct osd_state *sd, enum osd_layer layer,
764 * attribute mode to a normal mode. 1083 * attribute mode to a normal mode.
765 */ 1084 */
766 if (lconfig->pixfmt == PIXFMT_OSD_ATTR) { 1085 if (lconfig->pixfmt == PIXFMT_OSD_ATTR) {
767 winmd_mask |= 1086 if (sd->vpbe_type == VPBE_VERSION_1) {
768 OSD_OSDWIN1MD_ATN1E | OSD_OSDWIN1MD_RGB1E | 1087 winmd_mask |= OSD_OSDWIN1MD_ATN1E |
769 OSD_OSDWIN1MD_CLUTS1 | 1088 OSD_OSDWIN1MD_RGB1E | OSD_OSDWIN1MD_CLUTS1 |
770 OSD_OSDWIN1MD_BLND1 | OSD_OSDWIN1MD_TE1; 1089 OSD_OSDWIN1MD_BLND1 | OSD_OSDWIN1MD_TE1;
1090 } else {
1091 winmd_mask |= OSD_OSDWIN1MD_BMP1MD |
1092 OSD_OSDWIN1MD_CLUTS1 | OSD_OSDWIN1MD_BLND1 |
1093 OSD_OSDWIN1MD_TE1;
1094 }
771 } else { 1095 } else {
772 winmd_mask |= OSD_OSDWIN1MD_RGB1E; 1096 if (sd->vpbe_type == VPBE_VERSION_1) {
773 if (lconfig->pixfmt == PIXFMT_RGB565) 1097 winmd_mask |= OSD_OSDWIN1MD_RGB1E;
774 winmd |= OSD_OSDWIN1MD_RGB1E; 1098 if (lconfig->pixfmt == PIXFMT_RGB565)
1099 winmd |= OSD_OSDWIN1MD_RGB1E;
1100 } else if ((sd->vpbe_type == VPBE_VERSION_3)
1101 || (sd->vpbe_type == VPBE_VERSION_2)) {
1102 winmd_mask |= OSD_OSDWIN1MD_BMP1MD;
1103 switch (lconfig->pixfmt) {
1104 case PIXFMT_RGB565:
1105 winmd |=
1106 (1 << OSD_OSDWIN1MD_BMP1MD_SHIFT);
1107 break;
1108 case PIXFMT_RGB888:
1109 winmd |=
1110 (2 << OSD_OSDWIN1MD_BMP1MD_SHIFT);
1111 _osd_enable_rgb888_pixblend(sd,
1112 OSDWIN_OSD1);
1113 break;
1114 case PIXFMT_YCbCrI:
1115 case PIXFMT_YCrCbI:
1116 winmd |=
1117 (3 << OSD_OSDWIN1MD_BMP1MD_SHIFT);
1118 break;
1119 default:
1120 break;
1121 }
1122 }
775 1123
776 winmd_mask |= OSD_OSDWIN1MD_BMW1; 1124 winmd_mask |= OSD_OSDWIN1MD_BMW1;
777 switch (lconfig->pixfmt) { 1125 switch (lconfig->pixfmt) {
@@ -822,15 +1170,45 @@ static void _osd_set_layer_config(struct osd_state *sd, enum osd_layer layer,
822 * For YUV420P format the register contents are 1170 * For YUV420P format the register contents are
823 * duplicated in both VID registers 1171 * duplicated in both VID registers
824 */ 1172 */
825 osd_modify(sd, OSD_MISCCTL_S420D, ~OSD_MISCCTL_S420D, 1173 if (sd->vpbe_type == VPBE_VERSION_2) {
826 OSD_MISCCTL); 1174 if (lconfig->pixfmt == PIXFMT_NV12) {
1175 /* other window also */
1176 if (lconfig->interlaced) {
1177 winmd_mask |= OSD_VIDWINMD_VFF0;
1178 winmd |= OSD_VIDWINMD_VFF0;
1179 osd_modify(sd, winmd_mask, winmd,
1180 OSD_VIDWINMD);
1181 }
1182 osd_modify(sd, OSD_MISCCTL_S420D,
1183 OSD_MISCCTL_S420D, OSD_MISCCTL);
1184 osd_write(sd, lconfig->line_length >> 5,
1185 OSD_VIDWIN0OFST);
1186 osd_write(sd, lconfig->xpos, OSD_VIDWIN0XP);
1187 osd_write(sd, lconfig->xsize, OSD_VIDWIN0XL);
1188 } else {
1189 osd_modify(sd, OSD_MISCCTL_S420D,
1190 ~OSD_MISCCTL_S420D, OSD_MISCCTL);
1191 }
1192 }
827 1193
828 if (lconfig->interlaced) { 1194 if (lconfig->interlaced) {
829 osd_write(sd, lconfig->ypos >> 1, OSD_VIDWIN1YP); 1195 osd_write(sd, lconfig->ypos >> 1, OSD_VIDWIN1YP);
830 osd_write(sd, lconfig->ysize >> 1, OSD_VIDWIN1YL); 1196 osd_write(sd, lconfig->ysize >> 1, OSD_VIDWIN1YL);
1197 if ((sd->vpbe_type == VPBE_VERSION_2) &&
1198 lconfig->pixfmt == PIXFMT_NV12) {
1199 osd_write(sd, lconfig->ypos >> 1,
1200 OSD_VIDWIN0YP);
1201 osd_write(sd, lconfig->ysize >> 1,
1202 OSD_VIDWIN0YL);
1203 }
831 } else { 1204 } else {
832 osd_write(sd, lconfig->ypos, OSD_VIDWIN1YP); 1205 osd_write(sd, lconfig->ypos, OSD_VIDWIN1YP);
833 osd_write(sd, lconfig->ysize, OSD_VIDWIN1YL); 1206 osd_write(sd, lconfig->ysize, OSD_VIDWIN1YL);
1207 if ((sd->vpbe_type == VPBE_VERSION_2) &&
1208 lconfig->pixfmt == PIXFMT_NV12) {
1209 osd_write(sd, lconfig->ypos, OSD_VIDWIN0YP);
1210 osd_write(sd, lconfig->ysize, OSD_VIDWIN0YL);
1211 }
834 } 1212 }
835 break; 1213 break;
836 } 1214 }
@@ -1089,6 +1467,11 @@ static void _osd_init(struct osd_state *sd)
1089 osd_write(sd, 0, OSD_OSDWIN1MD); 1467 osd_write(sd, 0, OSD_OSDWIN1MD);
1090 osd_write(sd, 0, OSD_RECTCUR); 1468 osd_write(sd, 0, OSD_RECTCUR);
1091 osd_write(sd, 0, OSD_MISCCTL); 1469 osd_write(sd, 0, OSD_MISCCTL);
1470 if (sd->vpbe_type == VPBE_VERSION_3) {
1471 osd_write(sd, 0, OSD_VBNDRY);
1472 osd_write(sd, 0, OSD_EXTMODE);
1473 osd_write(sd, OSD_MISCCTL_DMANG, OSD_MISCCTL);
1474 }
1092} 1475}
1093 1476
1094static void osd_set_left_margin(struct osd_state *sd, u32 val) 1477static void osd_set_left_margin(struct osd_state *sd, u32 val)
@@ -1110,6 +1493,14 @@ static int osd_initialize(struct osd_state *osd)
1110 /* set default Cb/Cr order */ 1493 /* set default Cb/Cr order */
1111 osd->yc_pixfmt = PIXFMT_YCbCrI; 1494 osd->yc_pixfmt = PIXFMT_YCbCrI;
1112 1495
1496 if (osd->vpbe_type == VPBE_VERSION_3) {
1497 /*
1498 * ROM CLUT1 on the DM355 is similar (identical?) to ROM CLUT0
1499 * on the DM6446, so make ROM_CLUT1 the default on the DM355.
1500 */
1501 osd->rom_clut = ROM_CLUT1;
1502 }
1503
1113 _osd_set_field_inversion(osd, osd->field_inversion); 1504 _osd_set_field_inversion(osd, osd->field_inversion);
1114 _osd_set_rom_clut(osd, osd->rom_clut); 1505 _osd_set_rom_clut(osd, osd->rom_clut);
1115 1506
@@ -1208,23 +1599,7 @@ static struct platform_driver osd_driver = {
1208 }, 1599 },
1209}; 1600};
1210 1601
1211static int osd_init(void) 1602module_platform_driver(osd_driver);
1212{
1213 if (platform_driver_register(&osd_driver)) {
1214 printk(KERN_ERR "Unable to register davinci osd driver\n");
1215 return -ENODEV;
1216 }
1217
1218 return 0;
1219}
1220
1221static void osd_exit(void)
1222{
1223 platform_driver_unregister(&osd_driver);
1224}
1225
1226module_init(osd_init);
1227module_exit(osd_exit);
1228 1603
1229MODULE_LICENSE("GPL"); 1604MODULE_LICENSE("GPL");
1230MODULE_DESCRIPTION("DaVinci OSD Manager Driver"); 1605MODULE_DESCRIPTION("DaVinci OSD Manager Driver");
diff --git a/drivers/media/video/davinci/vpbe_venc.c b/drivers/media/video/davinci/vpbe_venc.c
index 03a3e5c65ee7..00e80f59d5d5 100644
--- a/drivers/media/video/davinci/vpbe_venc.c
+++ b/drivers/media/video/davinci/vpbe_venc.c
@@ -99,6 +99,8 @@ static inline u32 vdaccfg_write(struct v4l2_subdev *sd, u32 val)
99 return val; 99 return val;
100} 100}
101 101
102#define VDAC_COMPONENT 0x543
103#define VDAC_S_VIDEO 0x210
102/* This function sets the dac of the VPBE for various outputs 104/* This function sets the dac of the VPBE for various outputs
103 */ 105 */
104static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index) 106static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index)
@@ -109,11 +111,12 @@ static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index)
109 venc_write(sd, VENC_DACSEL, 0); 111 venc_write(sd, VENC_DACSEL, 0);
110 break; 112 break;
111 case 1: 113 case 1:
112 v4l2_dbg(debug, 1, sd, "Setting output to S-Video\n"); 114 v4l2_dbg(debug, 1, sd, "Setting output to Component\n");
113 venc_write(sd, VENC_DACSEL, 0x210); 115 venc_write(sd, VENC_DACSEL, VDAC_COMPONENT);
114 break; 116 break;
115 case 2: 117 case 2:
116 venc_write(sd, VENC_DACSEL, 0x543); 118 v4l2_dbg(debug, 1, sd, "Setting output to S-video\n");
119 venc_write(sd, VENC_DACSEL, VDAC_S_VIDEO);
117 break; 120 break;
118 default: 121 default:
119 return -EINVAL; 122 return -EINVAL;
@@ -124,6 +127,8 @@ static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index)
124 127
125static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable) 128static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable)
126{ 129{
130 struct venc_state *venc = to_state(sd);
131 struct venc_platform_data *pdata = venc->pdata;
127 v4l2_dbg(debug, 2, sd, "venc_enabledigitaloutput\n"); 132 v4l2_dbg(debug, 2, sd, "venc_enabledigitaloutput\n");
128 133
129 if (benable) { 134 if (benable) {
@@ -155,7 +160,8 @@ static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable)
155 160
156 /* Disable LCD output control (accepting default polarity) */ 161 /* Disable LCD output control (accepting default polarity) */
157 venc_write(sd, VENC_LCDOUT, 0); 162 venc_write(sd, VENC_LCDOUT, 0);
158 venc_write(sd, VENC_CMPNT, 0x100); 163 if (pdata->venc_type != VPBE_VERSION_3)
164 venc_write(sd, VENC_CMPNT, 0x100);
159 venc_write(sd, VENC_HSPLS, 0); 165 venc_write(sd, VENC_HSPLS, 0);
160 venc_write(sd, VENC_HINT, 0); 166 venc_write(sd, VENC_HINT, 0);
161 venc_write(sd, VENC_HSTART, 0); 167 venc_write(sd, VENC_HSTART, 0);
@@ -178,11 +184,14 @@ static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable)
178 } 184 }
179} 185}
180 186
187#define VDAC_CONFIG_SD_V3 0x0E21A6B6
188#define VDAC_CONFIG_SD_V2 0x081141CF
181/* 189/*
182 * setting NTSC mode 190 * setting NTSC mode
183 */ 191 */
184static int venc_set_ntsc(struct v4l2_subdev *sd) 192static int venc_set_ntsc(struct v4l2_subdev *sd)
185{ 193{
194 u32 val;
186 struct venc_state *venc = to_state(sd); 195 struct venc_state *venc = to_state(sd);
187 struct venc_platform_data *pdata = venc->pdata; 196 struct venc_platform_data *pdata = venc->pdata;
188 197
@@ -195,12 +204,22 @@ static int venc_set_ntsc(struct v4l2_subdev *sd)
195 204
196 venc_enabledigitaloutput(sd, 0); 205 venc_enabledigitaloutput(sd, 0);
197 206
198 /* to set VENC CLK DIV to 1 - final clock is 54 MHz */ 207 if (pdata->venc_type == VPBE_VERSION_3) {
199 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1); 208 venc_write(sd, VENC_CLKCTL, 0x01);
200 /* Set REC656 Mode */ 209 venc_write(sd, VENC_VIDCTL, 0);
201 venc_write(sd, VENC_YCCCTL, 0x1); 210 val = vdaccfg_write(sd, VDAC_CONFIG_SD_V3);
202 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAFRQ); 211 } else if (pdata->venc_type == VPBE_VERSION_2) {
203 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAUPS); 212 venc_write(sd, VENC_CLKCTL, 0x01);
213 venc_write(sd, VENC_VIDCTL, 0);
214 vdaccfg_write(sd, VDAC_CONFIG_SD_V2);
215 } else {
216 /* to set VENC CLK DIV to 1 - final clock is 54 MHz */
217 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1);
218 /* Set REC656 Mode */
219 venc_write(sd, VENC_YCCCTL, 0x1);
220 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAFRQ);
221 venc_modify(sd, VENC_VDPRO, 0, VENC_VDPRO_DAUPS);
222 }
204 223
205 venc_write(sd, VENC_VMOD, 0); 224 venc_write(sd, VENC_VMOD, 0);
206 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), 225 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT),
@@ -220,6 +239,7 @@ static int venc_set_ntsc(struct v4l2_subdev *sd)
220static int venc_set_pal(struct v4l2_subdev *sd) 239static int venc_set_pal(struct v4l2_subdev *sd)
221{ 240{
222 struct venc_state *venc = to_state(sd); 241 struct venc_state *venc = to_state(sd);
242 struct venc_platform_data *pdata = venc->pdata;
223 243
224 v4l2_dbg(debug, 2, sd, "venc_set_pal\n"); 244 v4l2_dbg(debug, 2, sd, "venc_set_pal\n");
225 245
@@ -230,10 +250,20 @@ static int venc_set_pal(struct v4l2_subdev *sd)
230 250
231 venc_enabledigitaloutput(sd, 0); 251 venc_enabledigitaloutput(sd, 0);
232 252
233 /* to set VENC CLK DIV to 1 - final clock is 54 MHz */ 253 if (pdata->venc_type == VPBE_VERSION_3) {
234 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1); 254 venc_write(sd, VENC_CLKCTL, 0x1);
235 /* Set REC656 Mode */ 255 venc_write(sd, VENC_VIDCTL, 0);
236 venc_write(sd, VENC_YCCCTL, 0x1); 256 vdaccfg_write(sd, VDAC_CONFIG_SD_V3);
257 } else if (pdata->venc_type == VPBE_VERSION_2) {
258 venc_write(sd, VENC_CLKCTL, 0x1);
259 venc_write(sd, VENC_VIDCTL, 0);
260 vdaccfg_write(sd, VDAC_CONFIG_SD_V2);
261 } else {
262 /* to set VENC CLK DIV to 1 - final clock is 54 MHz */
263 venc_modify(sd, VENC_VIDCTL, 0, 1 << 1);
264 /* Set REC656 Mode */
265 venc_write(sd, VENC_YCCCTL, 0x1);
266 }
237 267
238 venc_modify(sd, VENC_SYNCCTL, 1 << VENC_SYNCCTL_OVD_SHIFT, 268 venc_modify(sd, VENC_SYNCCTL, 1 << VENC_SYNCCTL_OVD_SHIFT,
239 VENC_SYNCCTL_OVD); 269 VENC_SYNCCTL_OVD);
@@ -252,6 +282,7 @@ static int venc_set_pal(struct v4l2_subdev *sd)
252 return 0; 282 return 0;
253} 283}
254 284
285#define VDAC_CONFIG_HD_V2 0x081141EF
255/* 286/*
256 * venc_set_480p59_94 287 * venc_set_480p59_94
257 * 288 *
@@ -263,6 +294,9 @@ static int venc_set_480p59_94(struct v4l2_subdev *sd)
263 struct venc_platform_data *pdata = venc->pdata; 294 struct venc_platform_data *pdata = venc->pdata;
264 295
265 v4l2_dbg(debug, 2, sd, "venc_set_480p59_94\n"); 296 v4l2_dbg(debug, 2, sd, "venc_set_480p59_94\n");
297 if ((pdata->venc_type != VPBE_VERSION_1) &&
298 (pdata->venc_type != VPBE_VERSION_2))
299 return -EINVAL;
266 300
267 /* Setup clock at VPSS & VENC for SD */ 301 /* Setup clock at VPSS & VENC for SD */
268 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_480P59_94) < 0) 302 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_480P59_94) < 0)
@@ -270,12 +304,18 @@ static int venc_set_480p59_94(struct v4l2_subdev *sd)
270 304
271 venc_enabledigitaloutput(sd, 0); 305 venc_enabledigitaloutput(sd, 0);
272 306
307 if (pdata->venc_type == VPBE_VERSION_2)
308 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
273 venc_write(sd, VENC_OSDCLK0, 0); 309 venc_write(sd, VENC_OSDCLK0, 0);
274 venc_write(sd, VENC_OSDCLK1, 1); 310 venc_write(sd, VENC_OSDCLK1, 1);
275 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ, 311
276 VENC_VDPRO_DAFRQ); 312 if (pdata->venc_type == VPBE_VERSION_1) {
277 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS, 313 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ,
278 VENC_VDPRO_DAUPS); 314 VENC_VDPRO_DAFRQ);
315 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS,
316 VENC_VDPRO_DAUPS);
317 }
318
279 venc_write(sd, VENC_VMOD, 0); 319 venc_write(sd, VENC_VMOD, 0);
280 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), 320 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT),
281 VENC_VMOD_VIE); 321 VENC_VMOD_VIE);
@@ -302,19 +342,27 @@ static int venc_set_576p50(struct v4l2_subdev *sd)
302 342
303 v4l2_dbg(debug, 2, sd, "venc_set_576p50\n"); 343 v4l2_dbg(debug, 2, sd, "venc_set_576p50\n");
304 344
345 if ((pdata->venc_type != VPBE_VERSION_1) &&
346 (pdata->venc_type != VPBE_VERSION_2))
347 return -EINVAL;
305 /* Setup clock at VPSS & VENC for SD */ 348 /* Setup clock at VPSS & VENC for SD */
306 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_576P50) < 0) 349 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_576P50) < 0)
307 return -EINVAL; 350 return -EINVAL;
308 351
309 venc_enabledigitaloutput(sd, 0); 352 venc_enabledigitaloutput(sd, 0);
310 353
354 if (pdata->venc_type == VPBE_VERSION_2)
355 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
356
311 venc_write(sd, VENC_OSDCLK0, 0); 357 venc_write(sd, VENC_OSDCLK0, 0);
312 venc_write(sd, VENC_OSDCLK1, 1); 358 venc_write(sd, VENC_OSDCLK1, 1);
313 359
314 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ, 360 if (pdata->venc_type == VPBE_VERSION_1) {
315 VENC_VDPRO_DAFRQ); 361 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ,
316 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS, 362 VENC_VDPRO_DAFRQ);
317 VENC_VDPRO_DAUPS); 363 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS,
364 VENC_VDPRO_DAUPS);
365 }
318 366
319 venc_write(sd, VENC_VMOD, 0); 367 venc_write(sd, VENC_VMOD, 0);
320 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT), 368 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT),
@@ -330,6 +378,63 @@ static int venc_set_576p50(struct v4l2_subdev *sd)
330 return 0; 378 return 0;
331} 379}
332 380
381/*
382 * venc_set_720p60_internal - Setup 720p60 in venc for dm365 only
383 */
384static int venc_set_720p60_internal(struct v4l2_subdev *sd)
385{
386 struct venc_state *venc = to_state(sd);
387 struct venc_platform_data *pdata = venc->pdata;
388
389 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_720P60) < 0)
390 return -EINVAL;
391
392 venc_enabledigitaloutput(sd, 0);
393
394 venc_write(sd, VENC_OSDCLK0, 0);
395 venc_write(sd, VENC_OSDCLK1, 1);
396
397 venc_write(sd, VENC_VMOD, 0);
398 /* DM365 component HD mode */
399 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT),
400 VENC_VMOD_VIE);
401 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD);
402 venc_modify(sd, VENC_VMOD, (HDTV_720P << VENC_VMOD_TVTYP_SHIFT),
403 VENC_VMOD_TVTYP);
404 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC);
405 venc_write(sd, VENC_XHINTVL, 0);
406 return 0;
407}
408
409/*
410 * venc_set_1080i30_internal - Setup 1080i30 in venc for dm365 only
411 */
412static int venc_set_1080i30_internal(struct v4l2_subdev *sd)
413{
414 struct venc_state *venc = to_state(sd);
415 struct venc_platform_data *pdata = venc->pdata;
416
417 if (pdata->setup_clock(VPBE_ENC_DV_PRESET, V4L2_DV_1080P30) < 0)
418 return -EINVAL;
419
420 venc_enabledigitaloutput(sd, 0);
421
422 venc_write(sd, VENC_OSDCLK0, 0);
423 venc_write(sd, VENC_OSDCLK1, 1);
424
425
426 venc_write(sd, VENC_VMOD, 0);
427 /* DM365 component HD mode */
428 venc_modify(sd, VENC_VMOD, (1 << VENC_VMOD_VIE_SHIFT),
429 VENC_VMOD_VIE);
430 venc_modify(sd, VENC_VMOD, VENC_VMOD_HDMD, VENC_VMOD_HDMD);
431 venc_modify(sd, VENC_VMOD, (HDTV_1080I << VENC_VMOD_TVTYP_SHIFT),
432 VENC_VMOD_TVTYP);
433 venc_modify(sd, VENC_VMOD, VENC_VMOD_VENC, VENC_VMOD_VENC);
434 venc_write(sd, VENC_XHINTVL, 0);
435 return 0;
436}
437
333static int venc_s_std_output(struct v4l2_subdev *sd, v4l2_std_id norm) 438static int venc_s_std_output(struct v4l2_subdev *sd, v4l2_std_id norm)
334{ 439{
335 v4l2_dbg(debug, 1, sd, "venc_s_std_output\n"); 440 v4l2_dbg(debug, 1, sd, "venc_s_std_output\n");
@@ -345,13 +450,30 @@ static int venc_s_std_output(struct v4l2_subdev *sd, v4l2_std_id norm)
345static int venc_s_dv_preset(struct v4l2_subdev *sd, 450static int venc_s_dv_preset(struct v4l2_subdev *sd,
346 struct v4l2_dv_preset *dv_preset) 451 struct v4l2_dv_preset *dv_preset)
347{ 452{
453 struct venc_state *venc = to_state(sd);
454 int ret;
455
348 v4l2_dbg(debug, 1, sd, "venc_s_dv_preset\n"); 456 v4l2_dbg(debug, 1, sd, "venc_s_dv_preset\n");
349 457
350 if (dv_preset->preset == V4L2_DV_576P50) 458 if (dv_preset->preset == V4L2_DV_576P50)
351 return venc_set_576p50(sd); 459 return venc_set_576p50(sd);
352 else if (dv_preset->preset == V4L2_DV_480P59_94) 460 else if (dv_preset->preset == V4L2_DV_480P59_94)
353 return venc_set_480p59_94(sd); 461 return venc_set_480p59_94(sd);
354 462 else if ((dv_preset->preset == V4L2_DV_720P60) &&
463 (venc->pdata->venc_type == VPBE_VERSION_2)) {
464 /* TBD setup internal 720p mode here */
465 ret = venc_set_720p60_internal(sd);
466 /* for DM365 VPBE, there is DAC inside */
467 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
468 return ret;
469 } else if ((dv_preset->preset == V4L2_DV_1080I30) &&
470 (venc->pdata->venc_type == VPBE_VERSION_2)) {
471 /* TBD setup internal 1080i mode here */
472 ret = venc_set_1080i30_internal(sd);
473 /* for DM365 VPBE, there is DAC inside */
474 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
475 return ret;
476 }
355 return -EINVAL; 477 return -EINVAL;
356} 478}
357 479
@@ -508,11 +630,41 @@ static int venc_probe(struct platform_device *pdev)
508 goto release_venc_mem_region; 630 goto release_venc_mem_region;
509 } 631 }
510 632
633 if (venc->pdata->venc_type != VPBE_VERSION_1) {
634 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
635 if (!res) {
636 dev_err(venc->pdev,
637 "Unable to get VDAC_CONFIG address map\n");
638 ret = -ENODEV;
639 goto unmap_venc_io;
640 }
641
642 if (!request_mem_region(res->start,
643 resource_size(res), "venc")) {
644 dev_err(venc->pdev,
645 "Unable to reserve VDAC_CONFIG MMIO region\n");
646 ret = -ENODEV;
647 goto unmap_venc_io;
648 }
649
650 venc->vdaccfg_reg = ioremap_nocache(res->start,
651 resource_size(res));
652 if (!venc->vdaccfg_reg) {
653 dev_err(venc->pdev,
654 "Unable to map VDAC_CONFIG IO space\n");
655 ret = -ENODEV;
656 goto release_vdaccfg_mem_region;
657 }
658 }
511 spin_lock_init(&venc->lock); 659 spin_lock_init(&venc->lock);
512 platform_set_drvdata(pdev, venc); 660 platform_set_drvdata(pdev, venc);
513 dev_notice(venc->pdev, "VENC sub device probe success\n"); 661 dev_notice(venc->pdev, "VENC sub device probe success\n");
514 return 0; 662 return 0;
515 663
664release_vdaccfg_mem_region:
665 release_mem_region(res->start, resource_size(res));
666unmap_venc_io:
667 iounmap(venc->venc_base);
516release_venc_mem_region: 668release_venc_mem_region:
517 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 669 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
518 release_mem_region(res->start, resource_size(res)); 670 release_mem_region(res->start, resource_size(res));
@@ -529,6 +681,11 @@ static int venc_remove(struct platform_device *pdev)
529 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 681 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
530 iounmap((void *)venc->venc_base); 682 iounmap((void *)venc->venc_base);
531 release_mem_region(res->start, resource_size(res)); 683 release_mem_region(res->start, resource_size(res));
684 if (venc->pdata->venc_type != VPBE_VERSION_1) {
685 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
686 iounmap((void *)venc->vdaccfg_reg);
687 release_mem_region(res->start, resource_size(res));
688 }
532 kfree(venc); 689 kfree(venc);
533 690
534 return 0; 691 return 0;
@@ -543,23 +700,7 @@ static struct platform_driver venc_driver = {
543 }, 700 },
544}; 701};
545 702
546static int venc_init(void) 703module_platform_driver(venc_driver);
547{
548 if (platform_driver_register(&venc_driver)) {
549 printk(KERN_ERR "Unable to register venc driver\n");
550 return -ENODEV;
551 }
552 return 0;
553}
554
555static void venc_exit(void)
556{
557 platform_driver_unregister(&venc_driver);
558 return;
559}
560
561module_init(venc_init);
562module_exit(venc_exit);
563 704
564MODULE_LICENSE("GPL"); 705MODULE_LICENSE("GPL");
565MODULE_DESCRIPTION("VPBE VENC Driver"); 706MODULE_DESCRIPTION("VPBE VENC Driver");
diff --git a/drivers/media/video/davinci/vpfe_capture.c b/drivers/media/video/davinci/vpfe_capture.c
index 5b38fc93ff28..20cf271a774b 100644
--- a/drivers/media/video/davinci/vpfe_capture.c
+++ b/drivers/media/video/davinci/vpfe_capture.c
@@ -2076,20 +2076,4 @@ static struct platform_driver vpfe_driver = {
2076 .remove = __devexit_p(vpfe_remove), 2076 .remove = __devexit_p(vpfe_remove),
2077}; 2077};
2078 2078
2079static __init int vpfe_init(void) 2079module_platform_driver(vpfe_driver);
2080{
2081 printk(KERN_NOTICE "vpfe_init\n");
2082 /* Register driver to the kernel */
2083 return platform_driver_register(&vpfe_driver);
2084}
2085
2086/*
2087 * vpfe_cleanup : This function un-registers device driver
2088 */
2089static void vpfe_cleanup(void)
2090{
2091 platform_driver_unregister(&vpfe_driver);
2092}
2093
2094module_init(vpfe_init);
2095module_exit(vpfe_cleanup);
diff --git a/drivers/media/video/davinci/vpif_capture.c b/drivers/media/video/davinci/vpif_capture.c
index 49e4deb50043..6504e40a31dd 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -2177,6 +2177,12 @@ static __init int vpif_probe(struct platform_device *pdev)
2177 return err; 2177 return err;
2178 } 2178 }
2179 2179
2180 err = v4l2_device_register(vpif_dev, &vpif_obj.v4l2_dev);
2181 if (err) {
2182 v4l2_err(vpif_dev->driver, "Error registering v4l2 device\n");
2183 return err;
2184 }
2185
2180 k = 0; 2186 k = 0;
2181 while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, k))) { 2187 while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, k))) {
2182 for (i = res->start; i <= res->end; i++) { 2188 for (i = res->start; i <= res->end; i++) {
@@ -2246,12 +2252,6 @@ static __init int vpif_probe(struct platform_device *pdev)
2246 goto probe_out; 2252 goto probe_out;
2247 } 2253 }
2248 2254
2249 err = v4l2_device_register(vpif_dev, &vpif_obj.v4l2_dev);
2250 if (err) {
2251 v4l2_err(vpif_dev->driver, "Error registering v4l2 device\n");
2252 goto probe_subdev_out;
2253 }
2254
2255 for (i = 0; i < subdev_count; i++) { 2255 for (i = 0; i < subdev_count; i++) {
2256 subdevdata = &config->subdev_info[i]; 2256 subdevdata = &config->subdev_info[i];
2257 vpif_obj.sd[i] = 2257 vpif_obj.sd[i] =
@@ -2281,7 +2281,6 @@ probe_subdev_out:
2281 2281
2282 j = VPIF_CAPTURE_MAX_DEVICES; 2282 j = VPIF_CAPTURE_MAX_DEVICES;
2283probe_out: 2283probe_out:
2284 v4l2_device_unregister(&vpif_obj.v4l2_dev);
2285 for (k = 0; k < j; k++) { 2284 for (k = 0; k < j; k++) {
2286 /* Get the pointer to the channel object */ 2285 /* Get the pointer to the channel object */
2287 ch = vpif_obj.dev[k]; 2286 ch = vpif_obj.dev[k];
@@ -2303,6 +2302,7 @@ vpif_int_err:
2303 if (res) 2302 if (res)
2304 i = res->end; 2303 i = res->end;
2305 } 2304 }
2305 v4l2_device_unregister(&vpif_obj.v4l2_dev);
2306 return err; 2306 return err;
2307} 2307}
2308 2308