blob: 39bd43758e2a38f95a6ba44611fe0ff1e8830eb5 [file] [log] [blame]
/* 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