Commit caff80c3 authored by Lad, Prabhakar's avatar Lad, Prabhakar Committed by Mauro Carvalho Chehab
Browse files

[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: default avatarLad, Prabhakar <prabhakar.lad@ti.com>
Signed-off-by: default avatarManjunath Hadli <manjunath.hadli@ti.com>
Acked-by: default avatarSekhar Nori <nsekhar@ti.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 5a89fac7
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -689,7 +689,7 @@ static struct vpbe_output dm644xevm_vpbe_outputs[] = {
			.std		= VENC_STD_ALL,
			.capabilities	= V4L2_OUT_CAP_STD,
		},
		.subdev_name	= VPBE_VENC_SUBDEV_NAME,
		.subdev_name	= DM644X_VPBE_VENC_SUBDEV_NAME,
		.default_mode	= "ntsc",
		.num_modes	= ARRAY_SIZE(dm644xevm_enc_std_timing),
		.modes		= dm644xevm_enc_std_timing,
@@ -701,7 +701,7 @@ static struct vpbe_output dm644xevm_vpbe_outputs[] = {
			.type		= V4L2_OUTPUT_TYPE_ANALOG,
			.capabilities	= V4L2_OUT_CAP_DV_TIMINGS,
		},
		.subdev_name	= VPBE_VENC_SUBDEV_NAME,
		.subdev_name	= DM644X_VPBE_VENC_SUBDEV_NAME,
		.default_mode	= "480p59_94",
		.num_modes	= ARRAY_SIZE(dm644xevm_enc_preset_timing),
		.modes		= dm644xevm_enc_preset_timing,
@@ -712,10 +712,10 @@ static struct vpbe_config dm644xevm_display_cfg = {
	.module_name	= "dm644x-vpbe-display",
	.i2c_adapter_id	= 1,
	.osd		= {
		.module_name	= VPBE_OSD_SUBDEV_NAME,
		.module_name	= DM644X_VPBE_OSD_SUBDEV_NAME,
	},
	.venc		= {
		.module_name	= VPBE_VENC_SUBDEV_NAME,
		.module_name	= DM644X_VPBE_VENC_SUBDEV_NAME,
	},
	.num_outputs	= ARRAY_SIZE(dm644xevm_vpbe_outputs),
	.outputs	= dm644xevm_vpbe_outputs,
+2 −8
Original line number Diff line number Diff line
@@ -669,19 +669,14 @@ static struct resource dm644x_osd_resources[] = {
	},
};

static struct osd_platform_data dm644x_osd_data = {
	.vpbe_type     = VPBE_VERSION_1,
};

static struct platform_device dm644x_osd_dev = {
	.name		= VPBE_OSD_SUBDEV_NAME,
	.name		= DM644X_VPBE_OSD_SUBDEV_NAME,
	.id		= -1,
	.num_resources	= ARRAY_SIZE(dm644x_osd_resources),
	.resource	= dm644x_osd_resources,
	.dev		= {
		.dma_mask		= &dm644x_video_dma_mask,
		.coherent_dma_mask	= DMA_BIT_MASK(32),
		.platform_data		= &dm644x_osd_data,
	},
};

@@ -751,12 +746,11 @@ static struct platform_device dm644x_vpbe_display = {
};

static struct venc_platform_data dm644x_venc_pdata = {
	.venc_type	= VPBE_VERSION_1,
	.setup_clock	= dm644x_venc_setup_clock,
};

static struct platform_device dm644x_venc_dev = {
	.name		= VPBE_VENC_SUBDEV_NAME,
	.name		= DM644X_VPBE_VENC_SUBDEV_NAME,
	.id		= -1,
	.num_resources	= ARRAY_SIZE(dm644x_venc_resources),
	.resource	= dm644x_venc_resources,
+2 −2
Original line number Diff line number Diff line
@@ -558,9 +558,9 @@ static int platform_device_get(struct device *dev, void *data)
	struct platform_device *pdev = to_platform_device(dev);
	struct vpbe_device *vpbe_dev = data;

	if (strcmp("vpbe-osd", pdev->name) == 0)
	if (strstr(pdev->name, "vpbe-osd") != NULL)
		vpbe_dev->osd_device = platform_get_drvdata(pdev);
	if (strcmp("vpbe-venc", pdev->name) == 0)
	if (strstr(pdev->name, "vpbe-venc") != NULL)
		vpbe_dev->venc_device = dev_get_platdata(&pdev->dev);

	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -1656,7 +1656,7 @@ static int vpbe_device_get(struct device *dev, void *data)
	if (strcmp("vpbe_controller", pdev->name) == 0)
		vpbe_disp->vpbe_dev = platform_get_drvdata(pdev);

	if (strcmp("vpbe-osd", pdev->name) == 0)
	if (strstr(pdev->name, "vpbe-osd") != NULL)
		vpbe_disp->osd_device = platform_get_drvdata(pdev);

	return 0;
+25 −10
Original line number Diff line number Diff line
@@ -39,7 +39,22 @@
#include <linux/io.h>
#include "vpbe_osd_regs.h"

#define MODULE_NAME	VPBE_OSD_SUBDEV_NAME
#define MODULE_NAME	"davinci-vpbe-osd"

static struct platform_device_id vpbe_osd_devtype[] = {
	{
		.name = DM644X_VPBE_OSD_SUBDEV_NAME,
		.driver_data = VPBE_VERSION_1,
	}, {
		.name = DM365_VPBE_OSD_SUBDEV_NAME,
		.driver_data = VPBE_VERSION_2,
	}, {
		.name = DM355_VPBE_OSD_SUBDEV_NAME,
		.driver_data = VPBE_VERSION_3,
	},
};

MODULE_DEVICE_TABLE(platform, vpbe_osd_devtype);

/* register access routines */
static inline u32 osd_read(struct osd_state *sd, u32 offset)
@@ -129,7 +144,7 @@ static int _osd_dm6446_vid0_pingpong(struct osd_state *sd,
	struct osd_platform_data *pdata;

	pdata = (struct osd_platform_data *)sd->dev->platform_data;
	if (pdata->field_inv_wa_enable) {
	if (pdata != NULL && pdata->field_inv_wa_enable) {

		if (!field_inversion || !lconfig->interlaced) {
			osd_write(sd, fb_base_phys & ~0x1F, OSD_VIDWIN0ADR);
@@ -1526,7 +1541,7 @@ static const struct vpbe_osd_ops osd_ops = {

static int osd_probe(struct platform_device *pdev)
{
	struct osd_platform_data *pdata;
	const struct platform_device_id *pdev_id;
	struct osd_state *osd;
	struct resource *res;
	int ret = 0;
@@ -1535,16 +1550,15 @@ static int osd_probe(struct platform_device *pdev)
	if (osd == NULL)
		return -ENOMEM;

	osd->dev = &pdev->dev;
	pdata = (struct osd_platform_data *)pdev->dev.platform_data;
	osd->vpbe_type = (enum vpbe_version)pdata->vpbe_type;
	if (NULL == pdev->dev.platform_data) {
		dev_err(osd->dev, "No platform data defined for OSD"
			" sub device\n");
		ret = -ENOENT;
	pdev_id = platform_get_device_id(pdev);
	if (!pdev_id) {
		ret = -EINVAL;
		goto free_mem;
	}

	osd->dev = &pdev->dev;
	osd->vpbe_type = pdev_id->driver_data;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		dev_err(osd->dev, "Unable to get OSD register address map\n");
@@ -1595,6 +1609,7 @@ static struct platform_driver osd_driver = {
		.name	= MODULE_NAME,
		.owner	= THIS_MODULE,
	},
	.id_table	= vpbe_osd_devtype
};

module_platform_driver(osd_driver);
Loading