/* linux/inclue/media/exynos_mc.h
 *
 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
 *
 * header file for exynos media device driver
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef GSC_MDEVICE_H_
#define GSC_MDEVICE_H_

#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/mutex.h>
#include <linux/device.h>
#include <media/media-device.h>
#include <media/media-entity.h>
#include <media/v4l2-device.h>
#include <media/v4l2-subdev.h>

#define err(fmt, args...) \
	printk(KERN_ERR "%s:%d: " fmt "\n", __func__, __LINE__, ##args)

#define MDEV_MODULE_NAME "exynos-mdev"
#define MAX_GSC_SUBDEV		3
#if defined(CONFIG_SOC_EXYNOS8890)
#define MAX_VPP_SUBDEV		9
#else
#define MAX_VPP_SUBDEV		4
#endif
#define MAX_DSIM_SUBDEV		2
#define MDEV_MAX_NUM		3

#define VPP_PAD_SOURCE		0
#define GSC_OUT_PAD_SINK	0
#define GSC_OUT_PAD_SOURCE	1

#define GSC_CAP_PAD_SINK	0
#define GSC_CAP_PAD_SOURCE	1

#define FLITE_PAD_SINK		0
#define FLITE_PAD_SOURCE_PREV	1
#define FLITE_PAD_SOURCE_CAMCORD	2
#define FLITE_PAD_SOURCE_MEM		3
#define FLITE_PADS_NUM		4

#define CSIS_PAD_SINK		0
#define CSIS_PAD_SOURCE		1
#define CSIS_PADS_NUM		2

#define MAX_CAMIF_CLIENTS	2
#if defined(CONFIG_SOC_EXYNOS5410)
#define MAX_CAMIF_CHANNEL	3
#else
#define MAX_CAMIF_CHANNEL	2
#endif

#define MXR_SUBDEV_NAME		"s5p-mixer"

#define GSC_MODULE_NAME			"exynos-gsc"
#define GSC_SUBDEV_NAME			"exynos-gsc-sd"
#define FIMD_MODULE_NAME		"s5p-fimd1"
#define FIMD_ENTITY_NAME		"s3c-fb-window"
#define FLITE_MODULE_NAME		"exynos-fimc-lite"
#define CSIS_MODULE_NAME		"s5p-mipi-csis"
#define DEX_WB_NAME			"dex-wb-sd"

#define GSC_CAP_GRP_ID			(1 << 0)
#define FLITE_GRP_ID			(1 << 1)
#define CSIS_GRP_ID			(1 << 2)
#define SENSOR_GRP_ID			(1 << 3)
#define FIMD_GRP_ID			(1 << 4)

#define SENSOR_MAX_ENTITIES		MAX_CAMIF_CLIENTS
#define FLITE_MAX_ENTITIES		MAX_CAMIF_CHANNEL
#define CSIS_MAX_ENTITIES		MAX_CAMIF_CHANNEL

enum decon_ioctl_for_sync {
	S3CFB_FLUSH_WORKQUEUE,
	S3CFB_DUMP_REGISTER,
};

enum gsc_ioctl_for_sync {
	GSC_SFR_UPDATE,
	GSC_WAIT_STOP,
};

enum vpp_sd_ioctl {
	VPP_WIN_CONFIG,
	VPP_STOP,
	VPP_TUI_PROTECT,
	VPP_GET_BTS_VAL,
	VPP_SET_BW,
	VPP_SET_ROT_MIF,
	VPP_WAIT_FOR_UPDATE,
	VPP_DUMP,
	VPP_WAIT_IDLE,
	VPP_WAIT_FOR_FRAMEDONE,
	VPP_CFW_CONFIG,
};

enum mdev_node {
	MDEV_OUTPUT,
	MDEV_CAPTURE,
	MDEV_ISP,
};

enum mxr_data_from {
	FROM_GSC_SD,
	FROM_MXR_VD,
};

struct exynos_media_ops {
	int (*power_off)(struct v4l2_subdev *sd);
};

struct exynos_entity_data {
	const struct exynos_media_ops *media_ops;
	enum mxr_data_from mxr_data_from;
};

/**
 * struct exynos_md - Exynos media device information
 * @media_dev: top level media device
 * @v4l2_dev: top level v4l2_device holding up the subdevs
 * @pdev: platform device this media device is hooked up into
 * @slock: spinlock protecting @sensor array
 * @id: media device IDs
 * @gsc_sd: each pointer of g-scaler's subdev array
 */
struct exynos_md {
	struct media_device	media_dev;
	struct v4l2_device	v4l2_dev;
	struct platform_device	*pdev;
	struct v4l2_subdev	*vpp_sd[MAX_VPP_SUBDEV];
	struct device		*vpp_dev[MAX_VPP_SUBDEV];
	struct v4l2_subdev	*gsc_sd[MAX_GSC_SUBDEV];
	struct v4l2_subdev	*gsc_wb_sd;
	struct v4l2_subdev	*gsc_cap_sd[MAX_GSC_SUBDEV];
	struct v4l2_subdev	*csis_sd[CSIS_MAX_ENTITIES];
	struct v4l2_subdev	*flite_sd[FLITE_MAX_ENTITIES];
	struct v4l2_subdev	*sensor_sd[SENSOR_MAX_ENTITIES];
	struct v4l2_subdev	*dsim_sd[MAX_DSIM_SUBDEV];
	struct v4l2_subdev	*hdmi_sd;
	u16			id;
	bool			is_flite_on;
	spinlock_t slock;
};

static int dummy_callback(struct device *dev, void *md)
{
	/* non-zero return stops iteration */
	return -1;
}

static inline void *module_name_to_driver_data(char *module_name)
{
	struct device_driver *drv;
	struct device *dev;
	void *driver_data;

	drv = driver_find(module_name, &platform_bus_type);
	if (drv) {
		dev = driver_find_device(drv, NULL, NULL, dummy_callback);
		driver_data = dev_get_drvdata(dev);
		return driver_data;
	} else
		return NULL;
}

/* print entity information for debug*/
static inline void entity_info_print(struct media_entity *me, struct device *dev)
{
	u16 num_pads = me->num_pads;
	u16 num_links = me->num_links;
	int i;

	dev_dbg(dev, "entity name : %s\n", me->name);
	dev_dbg(dev, "number of pads = %d\n", num_pads);
	for (i = 0; i < num_pads; ++i) {
		dev_dbg(dev, "pad[%d] flag : %s\n", i,
			(me->pads[i].flags == 1) ? "SINK" : "SOURCE");
	}

	dev_dbg(dev, "number of links = %d\n", num_links);

	for (i = 0; i < num_links; ++i) {
		dev_dbg(dev, "link[%d] info  =  ", i);
		dev_dbg(dev, "%s : %s[%d]  --->  %s : %s[%d]\n",
			me->links[i].source->entity->name,
			me->links[i].source->flags == 1 ? "SINK" : "SOURCE",
			me->links[i].source->index,
			me->links[i].sink->entity->name,
			me->links[i].sink->flags == 1 ? "SINK" : "SOURCE",
			me->links[i].sink->index);
	}
}
#endif
