Commit | Line | Data |
---|---|---|
d3953223 | 1 | /* |
0c9204d3 | 2 | * Copyright (C) 2011 - 2012 Samsung Electronics Co., Ltd. |
d3953223 SN |
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" | |
4af81310 | 21 | #include "fimc-lite.h" |
d3953223 SN |
22 | #include "mipi-csis.h" |
23 | ||
e2985a26 SN |
24 | #define FIMC_OF_NODE_NAME "fimc" |
25 | #define FIMC_LITE_OF_NODE_NAME "fimc-lite" | |
26 | #define FIMC_IS_OF_NODE_NAME "fimc-is" | |
27 | #define CSIS_OF_NODE_NAME "csis" | |
28 | ||
4af81310 | 29 | /* Group IDs of sensor, MIPI-CSIS, FIMC-LITE and the writeback subdevs. */ |
588c87be SN |
30 | #define GRP_ID_SENSOR (1 << 8) |
31 | #define GRP_ID_FIMC_IS_SENSOR (1 << 9) | |
32 | #define GRP_ID_WRITEBACK (1 << 10) | |
33 | #define GRP_ID_CSIS (1 << 11) | |
34 | #define GRP_ID_FIMC (1 << 12) | |
35 | #define GRP_ID_FLITE (1 << 13) | |
36 | #define GRP_ID_FIMC_IS (1 << 14) | |
d3953223 SN |
37 | |
38 | #define FIMC_MAX_SENSORS 8 | |
39 | #define FIMC_MAX_CAMCLKS 2 | |
40 | ||
41 | struct fimc_csis_info { | |
42 | struct v4l2_subdev *sd; | |
43 | int id; | |
44 | }; | |
45 | ||
46 | struct fimc_camclk_info { | |
47 | struct clk *clock; | |
48 | int use_count; | |
49 | unsigned long frequency; | |
50 | }; | |
51 | ||
52 | /** | |
53 | * struct fimc_sensor_info - image data source subdev information | |
54 | * @pdata: sensor's atrributes passed as media device's platform data | |
55 | * @subdev: image sensor v4l2 subdev | |
56 | * @host: fimc device the sensor is currently linked to | |
d3953223 SN |
57 | * |
58 | * This data structure applies to image sensor and the writeback subdevs. | |
59 | */ | |
60 | struct fimc_sensor_info { | |
56bc911a | 61 | struct fimc_source_info pdata; |
d3953223 SN |
62 | struct v4l2_subdev *subdev; |
63 | struct fimc_dev *host; | |
d3953223 SN |
64 | }; |
65 | ||
66 | /** | |
67 | * struct fimc_md - fimc media device information | |
68 | * @csis: MIPI CSIS subdevs data | |
69 | * @sensor: array of registered sensor subdevs | |
70 | * @num_sensors: actual number of registered sensors | |
71 | * @camclk: external sensor clock information | |
72 | * @fimc: array of registered fimc devices | |
73 | * @media_dev: top level media device | |
74 | * @v4l2_dev: top level v4l2_device holding up the subdevs | |
75 | * @pdev: platform device this media device is hooked up into | |
76 | * @user_subdev_api: true if subdevs are not configured by the host driver | |
77 | * @slock: spinlock protecting @sensor array | |
78 | */ | |
79 | struct fimc_md { | |
80 | struct fimc_csis_info csis[CSIS_MAX_ENTITIES]; | |
81 | struct fimc_sensor_info sensor[FIMC_MAX_SENSORS]; | |
82 | int num_sensors; | |
83 | struct fimc_camclk_info camclk[FIMC_MAX_CAMCLKS]; | |
4af81310 | 84 | struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS]; |
d3953223 SN |
85 | struct fimc_dev *fimc[FIMC_MAX_DEVS]; |
86 | struct media_device media_dev; | |
87 | struct v4l2_device v4l2_dev; | |
88 | struct platform_device *pdev; | |
89 | bool user_subdev_api; | |
90 | spinlock_t slock; | |
91 | }; | |
92 | ||
93 | #define is_subdev_pad(pad) (pad == NULL || \ | |
94 | media_entity_type(pad->entity) == MEDIA_ENT_T_V4L2_SUBDEV) | |
95 | ||
96 | #define me_subtype(me) \ | |
97 | ((me->type) & (MEDIA_ENT_TYPE_MASK | MEDIA_ENT_SUBTYPE_MASK)) | |
98 | ||
99 | #define subdev_has_devnode(__sd) (__sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE) | |
100 | ||
101 | static inline struct fimc_md *entity_to_fimc_mdev(struct media_entity *me) | |
102 | { | |
103 | return me->parent == NULL ? NULL : | |
104 | container_of(me->parent, struct fimc_md, media_dev); | |
105 | } | |
106 | ||
107 | static inline void fimc_md_graph_lock(struct fimc_dev *fimc) | |
108 | { | |
31d34d9b | 109 | mutex_lock(&fimc->vid_cap.vfd.entity.parent->graph_mutex); |
d3953223 SN |
110 | } |
111 | ||
112 | static inline void fimc_md_graph_unlock(struct fimc_dev *fimc) | |
113 | { | |
31d34d9b | 114 | mutex_unlock(&fimc->vid_cap.vfd.entity.parent->graph_mutex); |
d3953223 SN |
115 | } |
116 | ||
117 | int fimc_md_set_camclk(struct v4l2_subdev *sd, bool on); | |
d3953223 SN |
118 | |
119 | #endif |