Use pkg-config
[media-ctl.git] / src / subdev.h
1 /*
2  * Media controller test application
3  *
4  * Copyright (C) 2010 Ideas on board SPRL <laurent.pinchart@ideasonboard.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  */
19
20 #ifndef __SUBDEV_H__
21 #define __SUBDEV_H__
22
23 #include <linux/v4l2-subdev.h>
24
25 struct media_entity;
26
27 /**
28  * @brief Open a sub-device.
29  * @param entity - sub-device media entity.
30  *
31  * Open the V4L2 subdev device node associated with @a entity. The file
32  * descriptor is stored in the media_entity structure.
33  *
34  * @return 0 on success, or a negative error code on failure.
35  */
36 int v4l2_subdev_open(struct media_entity *entity);
37
38 /**
39  * @brief Close a sub-device.
40  * @param entity - sub-device media entity.
41  *
42  * Close the V4L2 subdev device node associated with the @a entity and opened by
43  * a previous call to v4l2_subdev_open() (either explicit or implicit).
44  */
45 void v4l2_subdev_close(struct media_entity *entity);
46
47 /**
48  * @brief Retrieve the format on a pad.
49  * @param entity - subdev-device media entity.
50  * @param format - format to be filled.
51  * @param pad - pad number.
52  * @param which - identifier of the format to get.
53  *
54  * Retrieve the current format on the @a entity @a pad and store it in the
55  * @a format structure.
56  *
57  * @a which is set to V4L2_SUBDEV_FORMAT_TRY to retrieve the try format stored
58  * in the file handle, of V4L2_SUBDEV_FORMAT_ACTIVE to retrieve the current
59  * active format.
60  *
61  * @return 0 on success, or a negative error code on failure.
62  */
63 int v4l2_subdev_get_format(struct media_entity *entity,
64         struct v4l2_mbus_framefmt *format, unsigned int pad,
65         enum v4l2_subdev_format_whence which);
66
67 /**
68  * @brief Set the format on a pad.
69  * @param entity - subdev-device media entity.
70  * @param format - format.
71  * @param pad - pad number.
72  * @param which - identifier of the format to set.
73  *
74  * Set the format on the @a entity @a pad to @a format. The driver is allowed to
75  * modify the requested format, in which case @a format is updated with the
76  * modifications.
77  *
78  * @a which is set to V4L2_SUBDEV_FORMAT_TRY to set the try format stored in the
79  * file handle, of V4L2_SUBDEV_FORMAT_ACTIVE to configure the device with an
80  * active format.
81  *
82  * @return 0 on success, or a negative error code on failure.
83  */
84 int v4l2_subdev_set_format(struct media_entity *entity,
85         struct v4l2_mbus_framefmt *format, unsigned int pad,
86         enum v4l2_subdev_format_whence which);
87
88 /**
89  * @brief Retrieve the crop rectangle on a pad.
90  * @param entity - subdev-device media entity.
91  * @param rect - crop rectangle to be filled.
92  * @param pad - pad number.
93  * @param which - identifier of the format to get.
94  *
95  * Retrieve the current crop rectangleon the @a entity @a pad and store it in
96  * the @a rect structure.
97  *
98  * @a which is set to V4L2_SUBDEV_FORMAT_TRY to retrieve the try crop rectangle
99  * stored in the file handle, of V4L2_SUBDEV_FORMAT_ACTIVE to retrieve the
100  * current active crop rectangle.
101  *
102  * @return 0 on success, or a negative error code on failure.
103  */
104 int v4l2_subdev_get_crop(struct media_entity *entity, struct v4l2_rect *rect,
105         unsigned int pad, enum v4l2_subdev_format_whence which);
106
107 /**
108  * @brief Set the crop rectangle on a pad.
109  * @param entity - subdev-device media entity.
110  * @param rect - crop rectangle.
111  * @param pad - pad number.
112  * @param which - identifier of the format to set.
113  *
114  * Set the crop rectangle on the @a entity @a pad to @a rect. The driver is
115  * allowed to modify the requested rectangle, in which case @a rect is updated
116  * with the modifications.
117  *
118  * @a which is set to V4L2_SUBDEV_FORMAT_TRY to set the try crop rectangle
119  * stored in the file handle, of V4L2_SUBDEV_FORMAT_ACTIVE to configure the
120  * device with an active crop rectangle.
121  *
122  * @return 0 on success, or a negative error code on failure.
123  */
124 int v4l2_subdev_set_crop(struct media_entity *entity, struct v4l2_rect *rect,
125         unsigned int pad, enum v4l2_subdev_format_whence which);
126
127 /**
128  * @brief Retrieve the frame interval on a sub-device.
129  * @param entity - subdev-device media entity.
130  * @param interval - frame interval to be filled.
131  *
132  * Retrieve the current frame interval on subdev @a entity and store it in the
133  * @a interval structure.
134  *
135  * Frame interval retrieving is usually supported only on devices at the
136  * beginning of video pipelines, such as sensors.
137  *
138  * @return 0 on success, or a negative error code on failure.
139  */
140
141 int v4l2_subdev_get_frame_interval(struct media_entity *entity,
142         struct v4l2_fract *interval);
143
144 /**
145  * @brief Set the frame interval on a sub-device.
146  * @param entity - subdev-device media entity.
147  * @param interval - frame interval.
148  *
149  * Set the frame interval on subdev @a entity to @a interval. The driver is
150  * allowed to modify the requested frame interval, in which case @a interval is
151  * updated with the modifications.
152  *
153  * Frame interval setting is usually supported only on devices at the beginning
154  * of video pipelines, such as sensors.
155  *
156  * @return 0 on success, or a negative error code on failure.
157  */
158 int v4l2_subdev_set_frame_interval(struct media_entity *entity,
159         struct v4l2_fract *interval);
160
161 #endif
162