aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/s5p-fimc/fimc-mdevice.h
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2011-09-01 05:01:08 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-09-06 16:35:52 -0400
commitd3953223b0905437fef7ce60506b5fdfaf98dda6 (patch)
tree12570704e36b7131a03ec31f0746ae459410d251 /drivers/media/video/s5p-fimc/fimc-mdevice.h
parent30c9939d79d6edf64092148842835893d156b672 (diff)
[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: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s5p-fimc/fimc-mdevice.h')
-rw-r--r--drivers/media/video/s5p-fimc/fimc-mdevice.h118
1 files changed, 118 insertions, 0 deletions
diff --git a/drivers/media/video/s5p-fimc/fimc-mdevice.h b/drivers/media/video/s5p-fimc/fimc-mdevice.h
new file mode 100644
index 000000000000..da3780823e7d
--- /dev/null
+++ b/drivers/media/video/s5p-fimc/fimc-mdevice.h
@@ -0,0 +1,118 @@
1/*
2 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef FIMC_MDEVICE_H_
10#define FIMC_MDEVICE_H_
11
12#include <linux/clk.h>
13#include <linux/platform_device.h>
14#include <linux/mutex.h>
15#include <media/media-device.h>
16#include <media/media-entity.h>
17#include <media/v4l2-device.h>
18#include <media/v4l2-subdev.h>
19
20#include "fimc-core.h"
21#include "mipi-csis.h"
22
23/* Group IDs of sensor, MIPI CSIS and the writeback subdevs. */
24#define SENSOR_GROUP_ID (1 << 8)
25#define CSIS_GROUP_ID (1 << 9)
26#define WRITEBACK_GROUP_ID (1 << 10)
27
28#define FIMC_MAX_SENSORS 8
29#define FIMC_MAX_CAMCLKS 2
30
31struct fimc_csis_info {
32 struct v4l2_subdev *sd;
33 int id;
34};
35
36struct fimc_camclk_info {
37 struct clk *clock;
38 int use_count;
39 unsigned long frequency;
40};
41
42/**
43 * struct fimc_sensor_info - image data source subdev information
44 * @pdata: sensor's atrributes passed as media device's platform data
45 * @subdev: image sensor v4l2 subdev
46 * @host: fimc device the sensor is currently linked to
47 * @clk_on: sclk_cam clock's state associated with this subdev
48 *
49 * This data structure applies to image sensor and the writeback subdevs.
50 */
51struct fimc_sensor_info {
52 struct s5p_fimc_isp_info *pdata;
53 struct v4l2_subdev *subdev;
54 struct fimc_dev *host;
55 bool clk_on;
56};
57
58/**
59 * struct fimc_md - fimc media device information
60 * @csis: MIPI CSIS subdevs data
61 * @sensor: array of registered sensor subdevs
62 * @num_sensors: actual number of registered sensors
63 * @camclk: external sensor clock information
64 * @fimc: array of registered fimc devices
65 * @media_dev: top level media device
66 * @v4l2_dev: top level v4l2_device holding up the subdevs
67 * @pdev: platform device this media device is hooked up into
68 * @user_subdev_api: true if subdevs are not configured by the host driver
69 * @slock: spinlock protecting @sensor array
70 */
71struct fimc_md {
72 struct fimc_csis_info csis[CSIS_MAX_ENTITIES];
73 struct fimc_sensor_info sensor[FIMC_MAX_SENSORS];
74 int num_sensors;
75 struct fimc_camclk_info camclk[FIMC_MAX_CAMCLKS];
76 struct fimc_dev *fimc[FIMC_MAX_DEVS];
77 struct media_device media_dev;
78 struct v4l2_device v4l2_dev;
79 struct platform_device *pdev;
80 bool user_subdev_api;
81 spinlock_t slock;
82};
83
84#define is_subdev_pad(pad) (pad == NULL || \
85 media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
86
87#define me_subtype(me) \
88 ((me->type) & (MEDIA_ENT_TYPE_MASK | MEDIA_ENT_SUBTYPE_MASK))
89
90#define subdev_has_devnode(__sd) (__sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)
91
92static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me)
93{
94 return me->parent == NULL ? NULL :
95 container_of(me->parent, struct fimc_md, media_dev);
96}
97
98static inline void fimc_md_graph_lock(struct fimc_dev *fimc)
99{
100 BUG_ON(fimc->vid_cap.vfd == NULL);
101 mutex_lock(&fimc->vid_cap.vfd->entity.parent->graph_mutex);
102}
103
104static inline void fimc_md_graph_unlock(struct fimc_dev *fimc)
105{
106 BUG_ON(fimc->vid_cap.vfd == NULL);
107 mutex_unlock(&fimc->vid_cap.vfd->entity.parent->graph_mutex);
108}
109
110int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on);
111void fimc_pipeline_prepare(struct fimc_dev *fimc, struct media_entity *me);
112int fimc_pipeline_initialize(struct fimc_dev *fimc, struct media_entity *me,
113 bool resume);
114int fimc_pipeline_shutdown(struct fimc_dev *fimc);
115int fimc_pipeline_s_power(struct fimc_dev *fimc, int state);
116int fimc_pipeline_s_stream(struct fimc_dev *fimc, int state);
117
118#endif