Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb3ed3fd authored by Niklas Söderlund's avatar Niklas Söderlund Committed by Mauro Carvalho Chehab
Browse files

media: rcar-vin: move model information to own struct



When Gen3 support is added to the driver more than model ID will be
different for the different SoCs. To avoid a lot of if statements in the
code create a struct rvin_info to store this information.

While we are at it rename the poorly chosen enum which contains the
different model IDs from chip_id to model_id. Also sort the compatible
string entries and make use of of_device_get_match_data() which will
always work as the driver is DT only, so there's always a valid match.

Signed-off-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 23525ef9
Loading
Loading
Loading
Loading
+42 −14
Original line number Original line Diff line number Diff line
@@ -241,21 +241,53 @@ static int rvin_digital_graph_init(struct rvin_dev *vin)
 * Platform Device Driver
 * Platform Device Driver
 */
 */


static const struct rvin_info rcar_info_h1 = {
	.model = RCAR_H1,
};

static const struct rvin_info rcar_info_m1 = {
	.model = RCAR_M1,
};

static const struct rvin_info rcar_info_gen2 = {
	.model = RCAR_GEN2,
};

static const struct of_device_id rvin_of_id_table[] = {
static const struct of_device_id rvin_of_id_table[] = {
	{ .compatible = "renesas,vin-r8a7794", .data = (void *)RCAR_GEN2 },
	{
	{ .compatible = "renesas,vin-r8a7793", .data = (void *)RCAR_GEN2 },
		.compatible = "renesas,vin-r8a7778",
	{ .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
		.data = &rcar_info_m1,
	{ .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 },
	},
	{ .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 },
	{
	{ .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 },
		.compatible = "renesas,vin-r8a7779",
	{ .compatible = "renesas,rcar-gen2-vin", .data = (void *)RCAR_GEN2 },
		.data = &rcar_info_h1,
	{ },
	},
	{
		.compatible = "renesas,vin-r8a7790",
		.data = &rcar_info_gen2,
	},
	{
		.compatible = "renesas,vin-r8a7791",
		.data = &rcar_info_gen2,
	},
	{
		.compatible = "renesas,vin-r8a7793",
		.data = &rcar_info_gen2,
	},
	{
		.compatible = "renesas,vin-r8a7794",
		.data = &rcar_info_gen2,
	},
	{
		.compatible = "renesas,rcar-gen2-vin",
		.data = &rcar_info_gen2,
	},
	{ /* Sentinel */ },
};
};
MODULE_DEVICE_TABLE(of, rvin_of_id_table);
MODULE_DEVICE_TABLE(of, rvin_of_id_table);


static int rcar_vin_probe(struct platform_device *pdev)
static int rcar_vin_probe(struct platform_device *pdev)
{
{
	const struct of_device_id *match;
	struct rvin_dev *vin;
	struct rvin_dev *vin;
	struct resource *mem;
	struct resource *mem;
	int irq, ret;
	int irq, ret;
@@ -264,12 +296,8 @@ static int rcar_vin_probe(struct platform_device *pdev)
	if (!vin)
	if (!vin)
		return -ENOMEM;
		return -ENOMEM;


	match = of_match_device(of_match_ptr(rvin_of_id_table), &pdev->dev);
	if (!match)
		return -ENODEV;

	vin->dev = &pdev->dev;
	vin->dev = &pdev->dev;
	vin->chip = (enum chip_id)match->data;
	vin->info = of_device_get_match_data(&pdev->dev);


	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (mem == NULL)
	if (mem == NULL)
+2 −1
Original line number Original line Diff line number Diff line
@@ -266,7 +266,8 @@ static int __rvin_try_format(struct rvin_dev *vin,
	pix->sizeimage = max_t(u32, pix->sizeimage,
	pix->sizeimage = max_t(u32, pix->sizeimage,
			       rvin_format_sizeimage(pix));
			       rvin_format_sizeimage(pix));


	if (vin->chip == RCAR_M1 && pix->pixelformat == V4L2_PIX_FMT_XBGR32) {
	if (vin->info->model == RCAR_M1 &&
	    pix->pixelformat == V4L2_PIX_FMT_XBGR32) {
		vin_err(vin, "pixel format XBGR32 not supported on M1\n");
		vin_err(vin, "pixel format XBGR32 not supported on M1\n");
		return -EINVAL;
		return -EINVAL;
	}
	}
+11 −3
Original line number Original line Diff line number Diff line
@@ -29,7 +29,7 @@
/* Address alignment mask for HW buffers */
/* Address alignment mask for HW buffers */
#define HW_BUFFER_MASK 0x7f
#define HW_BUFFER_MASK 0x7f


enum chip_id {
enum model_id {
	RCAR_H1,
	RCAR_H1,
	RCAR_M1,
	RCAR_M1,
	RCAR_GEN2,
	RCAR_GEN2,
@@ -86,11 +86,19 @@ struct rvin_graph_entity {
	unsigned int sink_pad;
	unsigned int sink_pad;
};
};


/**
 * struct rvin_info - Information about the particular VIN implementation
 * @model:		VIN model
 */
struct rvin_info {
	enum model_id model;
};

/**
/**
 * struct rvin_dev - Renesas VIN device structure
 * struct rvin_dev - Renesas VIN device structure
 * @dev:		(OF) device
 * @dev:		(OF) device
 * @base:		device I/O register space remapped to virtual memory
 * @base:		device I/O register space remapped to virtual memory
 * @chip:		type of VIN chip
 * @info:		info about VIN instance
 *
 *
 * @vdev:		V4L2 video device associated with VIN
 * @vdev:		V4L2 video device associated with VIN
 * @v4l2_dev:		V4L2 device
 * @v4l2_dev:		V4L2 device
@@ -119,7 +127,7 @@ struct rvin_graph_entity {
struct rvin_dev {
struct rvin_dev {
	struct device *dev;
	struct device *dev;
	void __iomem *base;
	void __iomem *base;
	enum chip_id chip;
	const struct rvin_info *info;


	struct video_device vdev;
	struct video_device vdev;
	struct v4l2_device v4l2_dev;
	struct v4l2_device v4l2_dev;