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

Commit d3953223 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab
Browse files

[media] s5p-fimc: Add the media device driver



Add a top level media device driver aggregating FIMC video devnodes,
MIPI-CSIS and sensor subdevs. This driver gathers all media entities
and creates the possible links between them during initialization. By
default some links will be activated to enable access to all available
sensors in the system. For example if there are sensors S0, S1 listed
in the media device platform data definition they will be by default
assigned to FIMC0, FIMC1 respectively, which in turn will corresponds
to separate /dev/video?.
There is enough FIMC H/W entities to cover all available physical camera
interfaces in the system.

The fimc media device driver is bound to the "s5p-fimc-md" platform device.
Such platform device should be created by board initialization code
and camera sensors description array need to be specified as its
platform data.

The media device driver also implements various video pipeline operations,
for enabling subdevs power, streaming, etc., which will be used by the
capture video node driver.

Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 30c9939d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -949,8 +949,9 @@ config VIDEO_MX2
	  Interface

config  VIDEO_SAMSUNG_S5P_FIMC
	tristate "Samsung S5P and EXYNOS4 camera host interface driver"
	depends on VIDEO_V4L2 && PLAT_S5P && PM_RUNTIME
	tristate "Samsung S5P and EXYNOS4 camera interface driver (EXPERIMENTAL)"
	depends on VIDEO_V4L2 && I2C && PLAT_S5P && PM_RUNTIME && \
		VIDEO_V4L2_SUBDEV_API && EXPERIMENTAL
	select VIDEOBUF2_DMA_CONTIG
	select V4L2_MEM2MEM_DEV
	---help---
+1 −1
Original line number Diff line number Diff line
s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-capture.o
s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-capture.o fimc-mdevice.o
s5p-csis-objs := mipi-csis.o

obj-$(CONFIG_VIDEO_S5P_MIPI_CSIS)	+= s5p-csis.o
+15 −18
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <media/videobuf2-dma-contig.h>

#include "fimc-core.h"
#include "fimc-mdevice.h"

static char *fimc_clocks[MAX_FIMC_CLOCKS] = {
	"sclk_fimc", "fimc"
@@ -1867,6 +1868,7 @@ static struct fimc_pix_limit s5p_pix_limit[4] = {
static struct samsung_fimc_variant fimc0_variant_s5p = {
	.has_inp_rot	 = 1,
	.has_out_rot	 = 1,
	.has_cam_if	 = 1,
	.min_inp_pixsize = 16,
	.min_out_pixsize = 16,
	.hor_offs_align	 = 8,
@@ -1875,6 +1877,7 @@ static struct samsung_fimc_variant fimc0_variant_s5p = {
};

static struct samsung_fimc_variant fimc2_variant_s5p = {
	.has_cam_if	 = 1,
	.min_inp_pixsize = 16,
	.min_out_pixsize = 16,
	.hor_offs_align	 = 8,
@@ -1886,6 +1889,7 @@ static struct samsung_fimc_variant fimc0_variant_s5pv210 = {
	.pix_hoff	 = 1,
	.has_inp_rot	 = 1,
	.has_out_rot	 = 1,
	.has_cam_if	 = 1,
	.min_inp_pixsize = 16,
	.min_out_pixsize = 16,
	.hor_offs_align	 = 8,
@@ -1897,6 +1901,7 @@ static struct samsung_fimc_variant fimc1_variant_s5pv210 = {
	.pix_hoff	 = 1,
	.has_inp_rot	 = 1,
	.has_out_rot	 = 1,
	.has_cam_if	 = 1,
	.has_mainscaler_ext = 1,
	.min_inp_pixsize = 16,
	.min_out_pixsize = 16,
@@ -1906,6 +1911,7 @@ static struct samsung_fimc_variant fimc1_variant_s5pv210 = {
};

static struct samsung_fimc_variant fimc2_variant_s5pv210 = {
	.has_cam_if	 = 1,
	.pix_hoff	 = 1,
	.min_inp_pixsize = 16,
	.min_out_pixsize = 16,
@@ -1918,6 +1924,7 @@ static struct samsung_fimc_variant fimc0_variant_exynos4 = {
	.pix_hoff	 = 1,
	.has_inp_rot	 = 1,
	.has_out_rot	 = 1,
	.has_cam_if	 = 1,
	.has_cistatus2	 = 1,
	.has_mainscaler_ext = 1,
	.min_inp_pixsize = 16,
@@ -1927,8 +1934,9 @@ static struct samsung_fimc_variant fimc0_variant_exynos4 = {
	.pix_limit	 = &s5p_pix_limit[1],
};

static struct samsung_fimc_variant fimc2_variant_exynos4 = {
static struct samsung_fimc_variant fimc3_variant_exynos4 = {
	.pix_hoff	 = 1,
	.has_cam_if	 = 1,
	.has_cistatus2	 = 1,
	.has_mainscaler_ext = 1,
	.min_inp_pixsize = 16,
@@ -1966,7 +1974,7 @@ static struct samsung_fimc_driverdata fimc_drvdata_exynos4 = {
		[0] = &fimc0_variant_exynos4,
		[1] = &fimc0_variant_exynos4,
		[2] = &fimc0_variant_exynos4,
		[3] = &fimc2_variant_exynos4,
		[3] = &fimc3_variant_exynos4,
	},
	.num_entities = 4,
	.lclk_frequency = 166000000UL,
@@ -1997,29 +2005,18 @@ static struct platform_driver fimc_driver = {
	.remove		= __devexit_p(fimc_remove),
	.id_table	= fimc_driver_ids,
	.driver = {
		.name	= MODULE_NAME,
		.name	= FIMC_MODULE_NAME,
		.owner	= THIS_MODULE,
		.pm     = &fimc_pm_ops,
	}
};

static int __init fimc_init(void)
int __init fimc_register_driver(void)
{
	int ret = platform_driver_register(&fimc_driver);
	if (ret)
		err("platform_driver_register failed: %d\n", ret);
	return ret;
	return platform_driver_probe(&fimc_driver, fimc_probe);
}

static void __exit fimc_exit(void)
void __exit fimc_unregister_driver(void)
{
	platform_driver_unregister(&fimc_driver);
}

module_init(fimc_init);
module_exit(fimc_exit);

MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>");
MODULE_DESCRIPTION("S5P FIMC camera host interface/video postprocessor driver");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0.1");
+15 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@
/* Time to wait for next frame VSYNC interrupt while stopping operation. */
#define FIMC_SHUTDOWN_TIMEOUT	((100*HZ)/1000)
#define MAX_FIMC_CLOCKS		2
#define MODULE_NAME		"s5p-fimc"
#define FIMC_MODULE_NAME	"s5p-fimc"
#define FIMC_MAX_DEVS		4
#define FIMC_MAX_OUT_BUFS	4
#define SCALER_MAX_HRATIO	64
@@ -308,6 +308,7 @@ struct fimc_m2m_device {
 * @reqbufs_count: the number of buffers requested in REQBUFS ioctl
 * @input_index: input (camera sensor) index
 * @refcnt: driver's private reference counter
 * @user_subdev_api: true if subdevs are not configured by the host driver
 */
struct fimc_vid_cap {
	struct fimc_ctx			*ctx;
@@ -325,6 +326,7 @@ struct fimc_vid_cap {
	unsigned int			reqbufs_count;
	int				input_index;
	int				refcnt;
	bool				user_subdev_api;
};

/**
@@ -355,6 +357,7 @@ struct fimc_pix_limit {
 * @has_cistatus2: 1 if CISTATUS2 register is present in this IP revision
 * @has_mainscaler_ext: 1 if extended mainscaler ratios in CIEXTEN register
 *			 are present in this IP revision
 * @has_cam_if: set if this instance has a camera input interface
 * @pix_limit: pixel size constraints for the scaler
 * @min_inp_pixsize: minimum input pixel size
 * @min_out_pixsize: minimum output pixel size
@@ -367,6 +370,7 @@ struct samsung_fimc_variant {
	unsigned int	has_out_rot:1;
	unsigned int	has_cistatus2:1;
	unsigned int	has_mainscaler_ext:1;
	unsigned int	has_cam_if:1;
	struct fimc_pix_limit *pix_limit;
	u16		min_inp_pixsize;
	u16		min_out_pixsize;
@@ -387,6 +391,12 @@ struct samsung_fimc_driverdata {
	int		num_entities;
};

struct fimc_pipeline {
	struct media_pipeline *pipe;
	struct v4l2_subdev *sensor;
	struct v4l2_subdev *csis;
};

struct fimc_ctx;

/**
@@ -408,6 +418,7 @@ struct fimc_ctx;
 * @vid_cap:	camera capture device information
 * @state:	flags used to synchronize m2m and capture mode operation
 * @alloc_ctx:	videobuf2 memory allocator context
 * @pipeline:	fimc video capture pipeline data structure
 */
struct fimc_dev {
	spinlock_t			slock;
@@ -427,6 +438,7 @@ struct fimc_dev {
	struct fimc_vid_cap		vid_cap;
	unsigned long			state;
	struct vb2_alloc_ctx		*alloc_ctx;
	struct fimc_pipeline		pipeline;
};

/**
@@ -645,6 +657,8 @@ int fimc_prepare_addr(struct fimc_ctx *ctx, struct vb2_buffer *vb,
int fimc_register_m2m_device(struct fimc_dev *fimc,
			     struct v4l2_device *v4l2_dev);
void fimc_unregister_m2m_device(struct fimc_dev *fimc);
int fimc_register_driver(void);
void fimc_unregister_driver(void);

/* -----------------------------------------------------*/
/* fimc-capture.c					*/
+829 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading