aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/davinci
diff options
context:
space:
mode:
authorLad, Prabhakar <prabhakar.lad@ti.com>2012-11-20 05:30:36 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-12-21 11:18:50 -0500
commitcaff80c35f923806b7e5ef312dce41663b5e99b9 (patch)
treea7dc2f10963df469808b7a52fd90276701d644f5 /drivers/media/platform/davinci
parent5a89fac7e90dd75b9783914fa351069d20fd8c54 (diff)
[media] davinci: vpbe: pass different platform names to handle different ip's
The vpbe driver can handle different platforms DM644X, DM36X and DM355. To differentiate between this platforms venc_type/vpbe_type was passed as part of platform data which was incorrect. The correct way to differentiate to handle this case is by passing different platform names. This patch creates platform_device_id[] array supporting different platforms and assigns id_table to the platform driver, and finally in the probe gets the actual device by using platform_get_device_id() and gets the appropriate driver data for that platform. Taking this approach will also make the DT transition easier. Signed-off-by: Lad, Prabhakar <prabhakar.lad@ti.com> Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com> Acked-by: Sekhar Nori <nsekhar@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/platform/davinci')
-rw-r--r--drivers/media/platform/davinci/vpbe.c4
-rw-r--r--drivers/media/platform/davinci/vpbe_display.c2
-rw-r--r--drivers/media/platform/davinci/vpbe_osd.c35
-rw-r--r--drivers/media/platform/davinci/vpbe_venc.c65
4 files changed, 72 insertions, 34 deletions
diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
index 7f5cf9b347b2..dd670cdb2c2a 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -558,9 +558,9 @@ static int platform_device_get(struct device *dev, void *data)
558 struct platform_device *pdev = to_platform_device(dev); 558 struct platform_device *pdev = to_platform_device(dev);
559 struct vpbe_device *vpbe_dev = data; 559 struct vpbe_device *vpbe_dev = data;
560 560
561 if (strcmp("vpbe-osd", pdev->name) == 0) 561 if (strstr(pdev->name, "vpbe-osd") != NULL)
562 vpbe_dev->osd_device = platform_get_drvdata(pdev); 562 vpbe_dev->osd_device = platform_get_drvdata(pdev);
563 if (strcmp("vpbe-venc", pdev->name) == 0) 563 if (strstr(pdev->name, "vpbe-venc") != NULL)
564 vpbe_dev->venc_device = dev_get_platdata(&pdev->dev); 564 vpbe_dev->venc_device = dev_get_platdata(&pdev->dev);
565 565
566 return 0; 566 return 0;
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index 2bfde7958fef..3846890ea707 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -1656,7 +1656,7 @@ static int vpbe_device_get(struct device *dev, void *data)
1656 if (strcmp("vpbe_controller", pdev->name) == 0) 1656 if (strcmp("vpbe_controller", pdev->name) == 0)
1657 vpbe_disp->vpbe_dev = platform_get_drvdata(pdev); 1657 vpbe_disp->vpbe_dev = platform_get_drvdata(pdev);
1658 1658
1659 if (strcmp("vpbe-osd", pdev->name) == 0) 1659 if (strstr(pdev->name, "vpbe-osd") != NULL)
1660 vpbe_disp->osd_device = platform_get_drvdata(pdev); 1660 vpbe_disp->osd_device = platform_get_drvdata(pdev);
1661 1661
1662 return 0; 1662 return 0;
diff --git a/drivers/media/platform/davinci/vpbe_osd.c b/drivers/media/platform/davinci/vpbe_osd.c
index 707f243f810d..12ad17c52ef3 100644
--- a/drivers/media/platform/davinci/vpbe_osd.c
+++ b/drivers/media/platform/davinci/vpbe_osd.c
@@ -39,7 +39,22 @@
39#include <linux/io.h> 39#include <linux/io.h>
40#include "vpbe_osd_regs.h" 40#include "vpbe_osd_regs.h"
41 41
42#define MODULE_NAME VPBE_OSD_SUBDEV_NAME 42#define MODULE_NAME "davinci-vpbe-osd"
43
44static struct platform_device_id vpbe_osd_devtype[] = {
45 {
46 .name = DM644X_VPBE_OSD_SUBDEV_NAME,
47 .driver_data = VPBE_VERSION_1,
48 }, {
49 .name = DM365_VPBE_OSD_SUBDEV_NAME,
50 .driver_data = VPBE_VERSION_2,
51 }, {
52 .name = DM355_VPBE_OSD_SUBDEV_NAME,
53 .driver_data = VPBE_VERSION_3,
54 },
55};
56
57MODULE_DEVICE_TABLE(platform, vpbe_osd_devtype);
43 58
44/* register access routines */ 59/* register access routines */
45static inline u32 osd_read(struct osd_state *sd, u32 offset) 60static inline u32 osd_read(struct osd_state *sd, u32 offset)
@@ -129,7 +144,7 @@ static int _osd_dm6446_vid0_pingpong(struct osd_state *sd,
129 struct osd_platform_data *pdata; 144 struct osd_platform_data *pdata;
130 145
131 pdata = (struct osd_platform_data *)sd->dev->platform_data; 146 pdata = (struct osd_platform_data *)sd->dev->platform_data;
132 if (pdata->field_inv_wa_enable) { 147 if (pdata != NULL && pdata->field_inv_wa_enable) {
133 148
134 if (!field_inversion || !lconfig->interlaced) { 149 if (!field_inversion || !lconfig->interlaced) {
135 osd_write(sd, fb_base_phys & ~0x1F, OSD_VIDWIN0ADR); 150 osd_write(sd, fb_base_phys & ~0x1F, OSD_VIDWIN0ADR);
@@ -1526,7 +1541,7 @@ static const struct vpbe_osd_ops osd_ops = {
1526 1541
1527static int osd_probe(struct platform_device *pdev) 1542static int osd_probe(struct platform_device *pdev)
1528{ 1543{
1529 struct osd_platform_data *pdata; 1544 const struct platform_device_id *pdev_id;
1530 struct osd_state *osd; 1545 struct osd_state *osd;
1531 struct resource *res; 1546 struct resource *res;
1532 int ret = 0; 1547 int ret = 0;
@@ -1535,16 +1550,15 @@ static int osd_probe(struct platform_device *pdev)
1535 if (osd == NULL) 1550 if (osd == NULL)
1536 return -ENOMEM; 1551 return -ENOMEM;
1537 1552
1538 osd->dev = &pdev->dev; 1553 pdev_id = platform_get_device_id(pdev);
1539 pdata = (struct osd_platform_data *)pdev->dev.platform_data; 1554 if (!pdev_id) {
1540 osd->vpbe_type = (enum vpbe_version)pdata->vpbe_type; 1555 ret = -EINVAL;
1541 if (NULL == pdev->dev.platform_data) {
1542 dev_err(osd->dev, "No platform data defined for OSD"
1543 " sub device\n");
1544 ret = -ENOENT;
1545 goto free_mem; 1556 goto free_mem;
1546 } 1557 }
1547 1558
1559 osd->dev = &pdev->dev;
1560 osd->vpbe_type = pdev_id->driver_data;
1561
1548 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1562 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1549 if (!res) { 1563 if (!res) {
1550 dev_err(osd->dev, "Unable to get OSD register address map\n"); 1564 dev_err(osd->dev, "Unable to get OSD register address map\n");
@@ -1595,6 +1609,7 @@ static struct platform_driver osd_driver = {
1595 .name = MODULE_NAME, 1609 .name = MODULE_NAME,
1596 .owner = THIS_MODULE, 1610 .owner = THIS_MODULE,
1597 }, 1611 },
1612 .id_table = vpbe_osd_devtype
1598}; 1613};
1599 1614
1600module_platform_driver(osd_driver); 1615module_platform_driver(osd_driver);
diff --git a/drivers/media/platform/davinci/vpbe_venc.c b/drivers/media/platform/davinci/vpbe_venc.c
index aed7369b962a..bdbebd59df98 100644
--- a/drivers/media/platform/davinci/vpbe_venc.c
+++ b/drivers/media/platform/davinci/vpbe_venc.c
@@ -38,7 +38,22 @@
38 38
39#include "vpbe_venc_regs.h" 39#include "vpbe_venc_regs.h"
40 40
41#define MODULE_NAME VPBE_VENC_SUBDEV_NAME 41#define MODULE_NAME "davinci-vpbe-venc"
42
43static struct platform_device_id vpbe_venc_devtype[] = {
44 {
45 .name = DM644X_VPBE_VENC_SUBDEV_NAME,
46 .driver_data = VPBE_VERSION_1,
47 }, {
48 .name = DM365_VPBE_VENC_SUBDEV_NAME,
49 .driver_data = VPBE_VERSION_2,
50 }, {
51 .name = DM355_VPBE_VENC_SUBDEV_NAME,
52 .driver_data = VPBE_VERSION_3,
53 },
54};
55
56MODULE_DEVICE_TABLE(platform, vpbe_venc_devtype);
42 57
43static int debug = 2; 58static int debug = 2;
44module_param(debug, int, 0644); 59module_param(debug, int, 0644);
@@ -54,6 +69,7 @@ struct venc_state {
54 spinlock_t lock; 69 spinlock_t lock;
55 void __iomem *venc_base; 70 void __iomem *venc_base;
56 void __iomem *vdaccfg_reg; 71 void __iomem *vdaccfg_reg;
72 enum vpbe_version venc_type;
57}; 73};
58 74
59static inline struct venc_state *to_state(struct v4l2_subdev *sd) 75static inline struct venc_state *to_state(struct v4l2_subdev *sd)
@@ -127,7 +143,7 @@ static int venc_set_dac(struct v4l2_subdev *sd, u32 out_index)
127static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable) 143static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable)
128{ 144{
129 struct venc_state *venc = to_state(sd); 145 struct venc_state *venc = to_state(sd);
130 struct venc_platform_data *pdata = venc->pdata; 146
131 v4l2_dbg(debug, 2, sd, "venc_enabledigitaloutput\n"); 147 v4l2_dbg(debug, 2, sd, "venc_enabledigitaloutput\n");
132 148
133 if (benable) { 149 if (benable) {
@@ -159,7 +175,7 @@ static void venc_enabledigitaloutput(struct v4l2_subdev *sd, int benable)
159 175
160 /* Disable LCD output control (accepting default polarity) */ 176 /* Disable LCD output control (accepting default polarity) */
161 venc_write(sd, VENC_LCDOUT, 0); 177 venc_write(sd, VENC_LCDOUT, 0);
162 if (pdata->venc_type != VPBE_VERSION_3) 178 if (venc->venc_type != VPBE_VERSION_3)
163 venc_write(sd, VENC_CMPNT, 0x100); 179 venc_write(sd, VENC_CMPNT, 0x100);
164 venc_write(sd, VENC_HSPLS, 0); 180 venc_write(sd, VENC_HSPLS, 0);
165 venc_write(sd, VENC_HINT, 0); 181 venc_write(sd, VENC_HINT, 0);
@@ -203,11 +219,11 @@ static int venc_set_ntsc(struct v4l2_subdev *sd)
203 219
204 venc_enabledigitaloutput(sd, 0); 220 venc_enabledigitaloutput(sd, 0);
205 221
206 if (pdata->venc_type == VPBE_VERSION_3) { 222 if (venc->venc_type == VPBE_VERSION_3) {
207 venc_write(sd, VENC_CLKCTL, 0x01); 223 venc_write(sd, VENC_CLKCTL, 0x01);
208 venc_write(sd, VENC_VIDCTL, 0); 224 venc_write(sd, VENC_VIDCTL, 0);
209 val = vdaccfg_write(sd, VDAC_CONFIG_SD_V3); 225 val = vdaccfg_write(sd, VDAC_CONFIG_SD_V3);
210 } else if (pdata->venc_type == VPBE_VERSION_2) { 226 } else if (venc->venc_type == VPBE_VERSION_2) {
211 venc_write(sd, VENC_CLKCTL, 0x01); 227 venc_write(sd, VENC_CLKCTL, 0x01);
212 venc_write(sd, VENC_VIDCTL, 0); 228 venc_write(sd, VENC_VIDCTL, 0);
213 vdaccfg_write(sd, VDAC_CONFIG_SD_V2); 229 vdaccfg_write(sd, VDAC_CONFIG_SD_V2);
@@ -238,7 +254,6 @@ static int venc_set_ntsc(struct v4l2_subdev *sd)
238static int venc_set_pal(struct v4l2_subdev *sd) 254static int venc_set_pal(struct v4l2_subdev *sd)
239{ 255{
240 struct venc_state *venc = to_state(sd); 256 struct venc_state *venc = to_state(sd);
241 struct venc_platform_data *pdata = venc->pdata;
242 257
243 v4l2_dbg(debug, 2, sd, "venc_set_pal\n"); 258 v4l2_dbg(debug, 2, sd, "venc_set_pal\n");
244 259
@@ -249,11 +264,11 @@ static int venc_set_pal(struct v4l2_subdev *sd)
249 264
250 venc_enabledigitaloutput(sd, 0); 265 venc_enabledigitaloutput(sd, 0);
251 266
252 if (pdata->venc_type == VPBE_VERSION_3) { 267 if (venc->venc_type == VPBE_VERSION_3) {
253 venc_write(sd, VENC_CLKCTL, 0x1); 268 venc_write(sd, VENC_CLKCTL, 0x1);
254 venc_write(sd, VENC_VIDCTL, 0); 269 venc_write(sd, VENC_VIDCTL, 0);
255 vdaccfg_write(sd, VDAC_CONFIG_SD_V3); 270 vdaccfg_write(sd, VDAC_CONFIG_SD_V3);
256 } else if (pdata->venc_type == VPBE_VERSION_2) { 271 } else if (venc->venc_type == VPBE_VERSION_2) {
257 venc_write(sd, VENC_CLKCTL, 0x1); 272 venc_write(sd, VENC_CLKCTL, 0x1);
258 venc_write(sd, VENC_VIDCTL, 0); 273 venc_write(sd, VENC_VIDCTL, 0);
259 vdaccfg_write(sd, VDAC_CONFIG_SD_V2); 274 vdaccfg_write(sd, VDAC_CONFIG_SD_V2);
@@ -293,8 +308,8 @@ static int venc_set_480p59_94(struct v4l2_subdev *sd)
293 struct venc_platform_data *pdata = venc->pdata; 308 struct venc_platform_data *pdata = venc->pdata;
294 309
295 v4l2_dbg(debug, 2, sd, "venc_set_480p59_94\n"); 310 v4l2_dbg(debug, 2, sd, "venc_set_480p59_94\n");
296 if ((pdata->venc_type != VPBE_VERSION_1) && 311 if (venc->venc_type != VPBE_VERSION_1 &&
297 (pdata->venc_type != VPBE_VERSION_2)) 312 venc->venc_type != VPBE_VERSION_2)
298 return -EINVAL; 313 return -EINVAL;
299 314
300 /* Setup clock at VPSS & VENC for SD */ 315 /* Setup clock at VPSS & VENC for SD */
@@ -303,12 +318,12 @@ static int venc_set_480p59_94(struct v4l2_subdev *sd)
303 318
304 venc_enabledigitaloutput(sd, 0); 319 venc_enabledigitaloutput(sd, 0);
305 320
306 if (pdata->venc_type == VPBE_VERSION_2) 321 if (venc->venc_type == VPBE_VERSION_2)
307 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); 322 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
308 venc_write(sd, VENC_OSDCLK0, 0); 323 venc_write(sd, VENC_OSDCLK0, 0);
309 venc_write(sd, VENC_OSDCLK1, 1); 324 venc_write(sd, VENC_OSDCLK1, 1);
310 325
311 if (pdata->venc_type == VPBE_VERSION_1) { 326 if (venc->venc_type == VPBE_VERSION_1) {
312 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ, 327 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ,
313 VENC_VDPRO_DAFRQ); 328 VENC_VDPRO_DAFRQ);
314 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS, 329 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS,
@@ -341,8 +356,8 @@ static int venc_set_576p50(struct v4l2_subdev *sd)
341 356
342 v4l2_dbg(debug, 2, sd, "venc_set_576p50\n"); 357 v4l2_dbg(debug, 2, sd, "venc_set_576p50\n");
343 358
344 if ((pdata->venc_type != VPBE_VERSION_1) && 359 if (venc->venc_type != VPBE_VERSION_1 &&
345 (pdata->venc_type != VPBE_VERSION_2)) 360 venc->venc_type != VPBE_VERSION_2)
346 return -EINVAL; 361 return -EINVAL;
347 /* Setup clock at VPSS & VENC for SD */ 362 /* Setup clock at VPSS & VENC for SD */
348 if (pdata->setup_clock(VPBE_ENC_CUSTOM_TIMINGS, 27000000) < 0) 363 if (pdata->setup_clock(VPBE_ENC_CUSTOM_TIMINGS, 27000000) < 0)
@@ -350,13 +365,13 @@ static int venc_set_576p50(struct v4l2_subdev *sd)
350 365
351 venc_enabledigitaloutput(sd, 0); 366 venc_enabledigitaloutput(sd, 0);
352 367
353 if (pdata->venc_type == VPBE_VERSION_2) 368 if (venc->venc_type == VPBE_VERSION_2)
354 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); 369 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
355 370
356 venc_write(sd, VENC_OSDCLK0, 0); 371 venc_write(sd, VENC_OSDCLK0, 0);
357 venc_write(sd, VENC_OSDCLK1, 1); 372 venc_write(sd, VENC_OSDCLK1, 1);
358 373
359 if (pdata->venc_type == VPBE_VERSION_1) { 374 if (venc->venc_type == VPBE_VERSION_1) {
360 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ, 375 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAFRQ,
361 VENC_VDPRO_DAFRQ); 376 VENC_VDPRO_DAFRQ);
362 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS, 377 venc_modify(sd, VENC_VDPRO, VENC_VDPRO_DAUPS,
@@ -460,14 +475,14 @@ static int venc_s_dv_timings(struct v4l2_subdev *sd,
460 else if (height == 480) 475 else if (height == 480)
461 return venc_set_480p59_94(sd); 476 return venc_set_480p59_94(sd);
462 else if ((height == 720) && 477 else if ((height == 720) &&
463 (venc->pdata->venc_type == VPBE_VERSION_2)) { 478 (venc->venc_type == VPBE_VERSION_2)) {
464 /* TBD setup internal 720p mode here */ 479 /* TBD setup internal 720p mode here */
465 ret = venc_set_720p60_internal(sd); 480 ret = venc_set_720p60_internal(sd);
466 /* for DM365 VPBE, there is DAC inside */ 481 /* for DM365 VPBE, there is DAC inside */
467 vdaccfg_write(sd, VDAC_CONFIG_HD_V2); 482 vdaccfg_write(sd, VDAC_CONFIG_HD_V2);
468 return ret; 483 return ret;
469 } else if ((height == 1080) && 484 } else if ((height == 1080) &&
470 (venc->pdata->venc_type == VPBE_VERSION_2)) { 485 (venc->venc_type == VPBE_VERSION_2)) {
471 /* TBD setup internal 1080i mode here */ 486 /* TBD setup internal 1080i mode here */
472 ret = venc_set_1080i30_internal(sd); 487 ret = venc_set_1080i30_internal(sd);
473 /* for DM365 VPBE, there is DAC inside */ 488 /* for DM365 VPBE, there is DAC inside */
@@ -556,7 +571,7 @@ static int venc_device_get(struct device *dev, void *data)
556 struct platform_device *pdev = to_platform_device(dev); 571 struct platform_device *pdev = to_platform_device(dev);
557 struct venc_state **venc = data; 572 struct venc_state **venc = data;
558 573
559 if (strcmp(MODULE_NAME, pdev->name) == 0) 574 if (strstr(pdev->name, "vpbe-venc") != NULL)
560 *venc = platform_get_drvdata(pdev); 575 *venc = platform_get_drvdata(pdev);
561 576
562 return 0; 577 return 0;
@@ -593,6 +608,7 @@ EXPORT_SYMBOL(venc_sub_dev_init);
593 608
594static int venc_probe(struct platform_device *pdev) 609static int venc_probe(struct platform_device *pdev)
595{ 610{
611 const struct platform_device_id *pdev_id;
596 struct venc_state *venc; 612 struct venc_state *venc;
597 struct resource *res; 613 struct resource *res;
598 int ret; 614 int ret;
@@ -601,6 +617,12 @@ static int venc_probe(struct platform_device *pdev)
601 if (venc == NULL) 617 if (venc == NULL)
602 return -ENOMEM; 618 return -ENOMEM;
603 619
620 pdev_id = platform_get_device_id(pdev);
621 if (!pdev_id) {
622 ret = -EINVAL;
623 goto free_mem;
624 }
625 venc->venc_type = pdev_id->driver_data;
604 venc->pdev = &pdev->dev; 626 venc->pdev = &pdev->dev;
605 venc->pdata = pdev->dev.platform_data; 627 venc->pdata = pdev->dev.platform_data;
606 if (NULL == venc->pdata) { 628 if (NULL == venc->pdata) {
@@ -630,7 +652,7 @@ static int venc_probe(struct platform_device *pdev)
630 goto release_venc_mem_region; 652 goto release_venc_mem_region;
631 } 653 }
632 654
633 if (venc->pdata->venc_type != VPBE_VERSION_1) { 655 if (venc->venc_type != VPBE_VERSION_1) {
634 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 656 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
635 if (!res) { 657 if (!res) {
636 dev_err(venc->pdev, 658 dev_err(venc->pdev,
@@ -681,7 +703,7 @@ static int venc_remove(struct platform_device *pdev)
681 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 703 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
682 iounmap((void *)venc->venc_base); 704 iounmap((void *)venc->venc_base);
683 release_mem_region(res->start, resource_size(res)); 705 release_mem_region(res->start, resource_size(res));
684 if (venc->pdata->venc_type != VPBE_VERSION_1) { 706 if (venc->venc_type != VPBE_VERSION_1) {
685 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 707 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
686 iounmap((void *)venc->vdaccfg_reg); 708 iounmap((void *)venc->vdaccfg_reg);
687 release_mem_region(res->start, resource_size(res)); 709 release_mem_region(res->start, resource_size(res));
@@ -698,6 +720,7 @@ static struct platform_driver venc_driver = {
698 .name = MODULE_NAME, 720 .name = MODULE_NAME,
699 .owner = THIS_MODULE, 721 .owner = THIS_MODULE,
700 }, 722 },
723 .id_table = vpbe_venc_devtype
701}; 724};
702 725
703module_platform_driver(venc_driver); 726module_platform_driver(venc_driver);