[media] s5p-fimc: Use v4l2_subdev internal ops to register video nodes
[deliverable/linux.git] / drivers / media / video / s5p-fimc / fimc-mdevice.h
CommitLineData
d3953223
SN
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)
693f5c40 27#define FIMC_GROUP_ID (1 << 11)
d3953223
SN
28
29#define FIMC_MAX_SENSORS 8
30#define FIMC_MAX_CAMCLKS 2
31
32struct fimc_csis_info {
33 struct v4l2_subdev *sd;
34 int id;
35};
36
37struct fimc_camclk_info {
38 struct clk *clock;
39 int use_count;
40 unsigned long frequency;
41};
42
43/**
44 * struct fimc_sensor_info - image data source subdev information
45 * @pdata: sensor's atrributes passed as media device's platform data
46 * @subdev: image sensor v4l2 subdev
47 * @host: fimc device the sensor is currently linked to
48 * @clk_on: sclk_cam clock's state associated with this subdev
49 *
50 * This data structure applies to image sensor and the writeback subdevs.
51 */
52struct fimc_sensor_info {
53 struct s5p_fimc_isp_info *pdata;
54 struct v4l2_subdev *subdev;
55 struct fimc_dev *host;
56 bool clk_on;
57};
58
59/**
60 * struct fimc_md - fimc media device information
61 * @csis: MIPI CSIS subdevs data
62 * @sensor: array of registered sensor subdevs
63 * @num_sensors: actual number of registered sensors
64 * @camclk: external sensor clock information
65 * @fimc: array of registered fimc devices
66 * @media_dev: top level media device
67 * @v4l2_dev: top level v4l2_device holding up the subdevs
68 * @pdev: platform device this media device is hooked up into
69 * @user_subdev_api: true if subdevs are not configured by the host driver
70 * @slock: spinlock protecting @sensor array
71 */
72struct fimc_md {
73 struct fimc_csis_info csis[CSIS_MAX_ENTITIES];
74 struct fimc_sensor_info sensor[FIMC_MAX_SENSORS];
75 int num_sensors;
76 struct fimc_camclk_info camclk[FIMC_MAX_CAMCLKS];
77 struct fimc_dev *fimc[FIMC_MAX_DEVS];
78 struct media_device media_dev;
79 struct v4l2_device v4l2_dev;
80 struct platform_device *pdev;
81 bool user_subdev_api;
82 spinlock_t slock;
83};
84
85#define is_subdev_pad(pad) (pad == NULL || \
86 media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
87
88#define me_subtype(me) \
89 ((me->type) & (MEDIA_ENT_TYPE_MASK | MEDIA_ENT_SUBTYPE_MASK))
90
91#define subdev_has_devnode(__sd) (__sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)
92
93static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me)
94{
95 return me->parent == NULL ? NULL :
96 container_of(me->parent, struct fimc_md, media_dev);
97}
98
99static inline void fimc_md_graph_lock(struct fimc_dev *fimc)
100{
101 BUG_ON(fimc->vid_cap.vfd == NULL);
102 mutex_lock(&fimc->vid_cap.vfd->entity.parent->graph_mutex);
103}
104
105static inline void fimc_md_graph_unlock(struct fimc_dev *fimc)
106{
107 BUG_ON(fimc->vid_cap.vfd == NULL);
108 mutex_unlock(&fimc->vid_cap.vfd->entity.parent->graph_mutex);
109}
110
111int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on);
112void fimc_pipeline_prepare(struct fimc_dev *fimc, struct media_entity *me);
113int fimc_pipeline_initialize(struct fimc_dev *fimc, struct media_entity *me,
114 bool resume);
115int fimc_pipeline_shutdown(struct fimc_dev *fimc);
116int fimc_pipeline_s_power(struct fimc_dev *fimc, int state);
117int fimc_pipeline_s_stream(struct fimc_dev *fimc, int state);
118
119#endif
This page took 0.137965 seconds and 5 git commands to generate.