1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /*! 18 * \file exynos_v4l2.h 19 * \brief header file for libv4l2 20 * \author Jinsung Yang (jsgood.yang (at) samsung.com) 21 * \date 2011/12/15 22 * 23 * <b>Revision History: </b> 24 * - 2011/12/15 : Jinsung Yang (jsgood.yang (at) samsung.com) \n 25 * Initial version 26 * 27 */ 28 29 /*! 30 * \defgroup exynos_v4l2 31 * \brief API for v4l2 32 * \addtogroup Exynos 33 */ 34 35 #ifndef __EXYNOS_LIB_V4L2_H__ 36 #define __EXYNOS_LIB_V4L2_H__ 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* V4L2 */ 43 #include <stdbool.h> 44 #include "videodev2.h" /* vendor specific videodev2.h */ 45 #include "videodev2_exynos_media.h" 46 47 /*! \ingroup exynos_v4l2 */ 48 int exynos_v4l2_open(const char *filename, int oflag, ...); 49 /*! \ingroup exynos_v4l2 */ 50 int exynos_v4l2_open_devname(const char *devname, int oflag, ...); 51 /*! \ingroup exynos_v4l2 */ 52 int exynos_v4l2_close(int fd); 53 /*! \ingroup exynos_v4l2 */ 54 bool exynos_v4l2_enuminput(int fd, int index, char *input_name_buf); 55 /*! \ingroup exynos_v4l2 */ 56 int exynos_v4l2_s_input(int fd, int index); 57 /*! \ingroup exynos_v4l2 */ 58 bool exynos_v4l2_querycap(int fd, unsigned int need_caps); 59 /*! \ingroup exynos_v4l2 */ 60 bool exynos_v4l2_enum_fmt(int fd, enum v4l2_buf_type type, unsigned int fmt); 61 /*! \ingroup exynos_v4l2 */ 62 int exynos_v4l2_g_fmt(int fd, struct v4l2_format *fmt); 63 /*! \ingroup exynos_v4l2 */ 64 int exynos_v4l2_s_fmt(int fd, struct v4l2_format *fmt); 65 /*! \ingroup exynos_v4l2 */ 66 int exynos_v4l2_try_fmt(int fd, struct v4l2_format *fmt); 67 /*! \ingroup exynos_v4l2 */ 68 int exynos_v4l2_reqbufs(int fd, struct v4l2_requestbuffers *req); 69 /*! \ingroup exynos_v4l2 */ 70 int exynos_v4l2_querybuf(int fd, struct v4l2_buffer *buf); 71 /*! \ingroup exynos_v4l2 */ 72 int exynos_v4l2_qbuf(int fd, struct v4l2_buffer *buf); 73 /*! \ingroup exynos_v4l2 */ 74 int exynos_v4l2_dqbuf(int fd, struct v4l2_buffer *buf); 75 /*! \ingroup exynos_v4l2 */ 76 int exynos_v4l2_streamon(int fd, enum v4l2_buf_type type); 77 /*! \ingroup exynos_v4l2 */ 78 int exynos_v4l2_streamoff(int fd, enum v4l2_buf_type type); 79 /*! \ingroup exynos_v4l2 */ 80 int exynos_v4l2_cropcap(int fd, struct v4l2_cropcap *crop); 81 /*! \ingroup exynos_v4l2 */ 82 int exynos_v4l2_g_crop(int fd, struct v4l2_crop *crop); 83 /*! \ingroup exynos_v4l2 */ 84 int exynos_v4l2_s_crop(int fd, struct v4l2_crop *crop); 85 /*! \ingroup exynos_v4l2 */ 86 int exynos_v4l2_g_ctrl(int fd, unsigned int id, int *value); 87 /*! \ingroup exynos_v4l2 */ 88 int exynos_v4l2_s_ctrl(int fd, unsigned int id, int value); 89 /*! \ingroup exynos_v4l2 */ 90 int exynos_v4l2_g_parm(int fd, struct v4l2_streamparm *streamparm); 91 /*! \ingroup exynos_v4l2 */ 92 int exynos_v4l2_s_parm(int fd, struct v4l2_streamparm *streamparm); 93 /*! \ingroup exynos_v4l2 */ 94 int exynos_v4l2_g_ext_ctrl(int fd, struct v4l2_ext_controls *ctrl); 95 /*! \ingroup exynos_v4l2 */ 96 int exynos_v4l2_s_ext_ctrl(int fd, struct v4l2_ext_controls *ctrl); 97 98 /* V4L2_SUBDEV */ 99 #include <v4l2-subdev.h> 100 101 /*! \ingroup exynos_v4l2 */ 102 int exynos_subdev_open(const char *filename, int oflag, ...); 103 /*! \ingroup exynos_v4l2 */ 104 int exynos_subdev_open_devname(const char *devname, int oflag, ...); 105 /*! \ingroup exynos_v4l2 */ 106 int exynos_subdev_enum_frame_size(int fd, struct v4l2_subdev_frame_size_enum *frame_size_enum); 107 /*! \ingroup exynos_v4l2 */ 108 int exynos_subdev_g_fmt(int fd, struct v4l2_subdev_format *fmt); 109 /*! \ingroup exynos_v4l2 */ 110 int exynos_subdev_s_fmt(int fd, struct v4l2_subdev_format *fmt); 111 /*! \ingroup exynos_v4l2 */ 112 int exynos_subdev_g_crop(int fd, struct v4l2_subdev_crop *crop); 113 /*! \ingroup exynos_v4l2 */ 114 int exynos_subdev_s_crop(int fd, struct v4l2_subdev_crop *crop); 115 /*! \ingroup exynos_v4l2 */ 116 int exynos_subdev_enum_frame_interval(int fd, struct v4l2_subdev_frame_interval_enum *frame_internval_enum); 117 /*! \ingroup exynos_v4l2 */ 118 int exynos_subdev_g_frame_interval(int fd, struct v4l2_subdev_frame_interval *frame_internval_enum); 119 /*! \ingroup exynos_v4l2 */ 120 int exynos_subdev_s_frame_interval(int fd, struct v4l2_subdev_frame_interval *frame_internval_enum); 121 /*! \ingroup exynos_v4l2 */ 122 int exynos_subdev_enum_mbus_code(int fd, struct v4l2_subdev_mbus_code_enum *mbus_code_enum); 123 124 /* MEDIA CONTORLLER */ 125 #include <media.h> 126 127 /*! media_link 128 * \ingroup exynos_v4l2 129 */ 130 struct media_link { 131 struct media_pad *source; 132 struct media_pad *sink; 133 struct media_link *twin; 134 __u32 flags; 135 __u32 padding[3]; 136 }; 137 138 /*! media_link 139 * \ingroup exynos_v4l2 140 */ 141 struct media_pad { 142 struct media_entity *entity; 143 __u32 index; 144 __u32 flags; 145 __u32 padding[3]; 146 }; 147 148 /*! media_link 149 * \ingroup exynos_v4l2 150 */ 151 struct media_entity { 152 struct media_device *media; 153 struct media_entity_desc info; 154 struct media_pad *pads; 155 struct media_link *links; 156 unsigned int max_links; 157 unsigned int num_links; 158 159 char devname[32]; 160 int fd; 161 __u32 padding[6]; 162 }; 163 164 /*! media_link 165 * \ingroup exynos_v4l2 166 */ 167 struct media_device { 168 int fd; 169 struct media_entity *entities; 170 unsigned int entities_count; 171 void (*debug_handler)(void *, ...); 172 void *debug_priv; 173 __u32 padding[6]; 174 }; 175 176 /*! \ingroup exynos_v4l2 */ 177 struct media_device *exynos_media_open(const char *filename); 178 /*! \ingroup exynos_v4l2 */ 179 void exynos_media_close(struct media_device *media); 180 /*! \ingroup exynos_v4l2 */ 181 struct media_pad *exynos_media_entity_remote_source(struct media_pad *pad); 182 /*! \ingroup exynos_v4l2 */ 183 struct media_entity *exynos_media_get_entity_by_name(struct media_device *media, const char *name, size_t length); 184 /*! \ingroup exynos_v4l2 */ 185 struct media_entity *exynos_media_get_entity_by_id(struct media_device *media, __u32 id); 186 /*! \ingroup exynos_v4l2 */ 187 int exynos_media_setup_link(struct media_device *media, struct media_pad *source, struct media_pad *sink, __u32 flags); 188 /*! \ingroup exynos_v4l2 */ 189 int exynos_media_reset_links(struct media_device *media); 190 /*! \ingroup exynos_v4l2 */ 191 struct media_pad *exynos_media_parse_pad(struct media_device *media, const char *p, char **endp); 192 /*! \ingroup exynos_v4l2 */ 193 struct media_link *exynos_media_parse_link(struct media_device *media, const char *p, char **endp); 194 /*! \ingroup exynos_v4l2 */ 195 int exynos_media_parse_setup_link(struct media_device *media, const char *p, char **endp); 196 /*! \ingroup exynos_v4l2 */ 197 int exynos_media_parse_setup_links(struct media_device *media, const char *p); 198 199 #ifdef __cplusplus 200 } 201 #endif 202 203 #endif /* __EXYNOS_LIB_V4L2_H__ */ 204