diff options
Diffstat (limited to 'include/media/v4l2-common.h')
| -rw-r--r-- | include/media/v4l2-common.h | 145 |
1 files changed, 111 insertions, 34 deletions
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index aac8b7b6e691..e0d95a7c5d48 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h | |||
| @@ -28,7 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | #include <media/v4l2-dev.h> | 29 | #include <media/v4l2-dev.h> |
| 30 | 30 | ||
| 31 | /* Common printk constucts for v4l-i2c drivers. These macros create a unique | 31 | /* Common printk constructs for v4l-i2c drivers. These macros create a unique |
| 32 | prefix consisting of the driver name, the adapter number and the i2c | 32 | prefix consisting of the driver name, the adapter number and the i2c |
| 33 | address. */ | 33 | address. */ |
| 34 | #define v4l_printk(level, name, adapter, addr, fmt, arg...) \ | 34 | #define v4l_printk(level, name, adapter, addr, fmt, arg...) \ |
| @@ -50,7 +50,7 @@ | |||
| 50 | /* These three macros assume that the debug level is set with a module | 50 | /* These three macros assume that the debug level is set with a module |
| 51 | parameter called 'debug'. */ | 51 | parameter called 'debug'. */ |
| 52 | #define v4l_dbg(level, debug, client, fmt, arg...) \ | 52 | #define v4l_dbg(level, debug, client, fmt, arg...) \ |
| 53 | do { \ | 53 | do { \ |
| 54 | if (debug >= (level)) \ | 54 | if (debug >= (level)) \ |
| 55 | v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \ | 55 | v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \ |
| 56 | } while (0) | 56 | } while (0) |
| @@ -80,9 +80,9 @@ | |||
| 80 | /* These three macros assume that the debug level is set with a module | 80 | /* These three macros assume that the debug level is set with a module |
| 81 | parameter called 'debug'. */ | 81 | parameter called 'debug'. */ |
| 82 | #define v4l2_dbg(level, debug, dev, fmt, arg...) \ | 82 | #define v4l2_dbg(level, debug, dev, fmt, arg...) \ |
| 83 | do { \ | 83 | do { \ |
| 84 | if (debug >= (level)) \ | 84 | if (debug >= (level)) \ |
| 85 | v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); \ | 85 | v4l2_printk(KERN_DEBUG, dev, fmt , ## arg); \ |
| 86 | } while (0) | 86 | } while (0) |
| 87 | 87 | ||
| 88 | /** | 88 | /** |
| @@ -127,7 +127,7 @@ struct v4l2_subdev_ops; | |||
| 127 | * @client_type: name of the chip that's on the adapter. | 127 | * @client_type: name of the chip that's on the adapter. |
| 128 | * @addr: I2C address. If zero, it will use @probe_addrs | 128 | * @addr: I2C address. If zero, it will use @probe_addrs |
| 129 | * @probe_addrs: array with a list of address. The last entry at such | 129 | * @probe_addrs: array with a list of address. The last entry at such |
| 130 | * array should be %I2C_CLIENT_END. | 130 | * array should be %I2C_CLIENT_END. |
| 131 | * | 131 | * |
| 132 | * returns a &struct v4l2_subdev pointer. | 132 | * returns a &struct v4l2_subdev pointer. |
| 133 | */ | 133 | */ |
| @@ -146,7 +146,7 @@ struct i2c_board_info; | |||
| 146 | * @info: pointer to struct i2c_board_info used to replace the irq, | 146 | * @info: pointer to struct i2c_board_info used to replace the irq, |
| 147 | * platform_data and addr arguments. | 147 | * platform_data and addr arguments. |
| 148 | * @probe_addrs: array with a list of address. The last entry at such | 148 | * @probe_addrs: array with a list of address. The last entry at such |
| 149 | * array should be %I2C_CLIENT_END. | 149 | * array should be %I2C_CLIENT_END. |
| 150 | * | 150 | * |
| 151 | * returns a &struct v4l2_subdev pointer. | 151 | * returns a &struct v4l2_subdev pointer. |
| 152 | */ | 152 | */ |
| @@ -174,17 +174,43 @@ void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, | |||
| 174 | */ | 174 | */ |
| 175 | unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd); | 175 | unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd); |
| 176 | 176 | ||
| 177 | /** | ||
| 178 | * enum v4l2_i2c_tuner_type - specifies the range of tuner address that | ||
| 179 | * should be used when seeking for I2C devices. | ||
| 180 | * | ||
| 181 | * @ADDRS_RADIO: Radio tuner addresses. | ||
| 182 | * Represent the following I2C addresses: | ||
| 183 | * 0x10 (if compiled with tea5761 support) | ||
| 184 | * and 0x60. | ||
| 185 | * @ADDRS_DEMOD: Demod tuner addresses. | ||
| 186 | * Represent the following I2C addresses: | ||
| 187 | * 0x42, 0x43, 0x4a and 0x4b. | ||
| 188 | * @ADDRS_TV: TV tuner addresses. | ||
| 189 | * Represent the following I2C addresses: | ||
| 190 | * 0x42, 0x43, 0x4a, 0x4b, 0x60, 0x61, 0x62, | ||
| 191 | * 0x63 and 0x64. | ||
| 192 | * @ADDRS_TV_WITH_DEMOD: TV tuner addresses if demod is present, this | ||
| 193 | * excludes addresses used by the demodulator | ||
| 194 | * from the list of candidates. | ||
| 195 | * Represent the following I2C addresses: | ||
| 196 | * 0x60, 0x61, 0x62, 0x63 and 0x64. | ||
| 197 | * | ||
| 198 | * NOTE: All I2C addresses above use the 7-bit notation. | ||
| 199 | */ | ||
| 177 | enum v4l2_i2c_tuner_type { | 200 | enum v4l2_i2c_tuner_type { |
| 178 | ADDRS_RADIO, /* Radio tuner addresses */ | 201 | ADDRS_RADIO, |
| 179 | ADDRS_DEMOD, /* Demod tuner addresses */ | 202 | ADDRS_DEMOD, |
| 180 | ADDRS_TV, /* TV tuner addresses */ | 203 | ADDRS_TV, |
| 181 | /* TV tuner addresses if demod is present, this excludes | ||
| 182 | addresses used by the demodulator from the list of | ||
| 183 | candidates. */ | ||
| 184 | ADDRS_TV_WITH_DEMOD, | 204 | ADDRS_TV_WITH_DEMOD, |
| 185 | }; | 205 | }; |
| 186 | /* Return a list of I2C tuner addresses to probe. Use only if the tuner | 206 | /** |
| 187 | addresses are unknown. */ | 207 | * v4l2_i2c_tuner_addrs - Return a list of I2C tuner addresses to probe. |
| 208 | * | ||
| 209 | * @type: type of the tuner to seek, as defined by | ||
| 210 | * &enum v4l2_i2c_tuner_type. | ||
| 211 | * | ||
| 212 | * NOTE: Use only if the tuner addresses are unknown. | ||
| 213 | */ | ||
| 188 | const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type); | 214 | const unsigned short *v4l2_i2c_tuner_addrs(enum v4l2_i2c_tuner_type type); |
| 189 | 215 | ||
| 190 | /* ------------------------------------------------------------------------- */ | 216 | /* ------------------------------------------------------------------------- */ |
| @@ -224,10 +250,14 @@ void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi, | |||
| 224 | 250 | ||
| 225 | /* ------------------------------------------------------------------------- */ | 251 | /* ------------------------------------------------------------------------- */ |
| 226 | 252 | ||
| 227 | /* Note: these remaining ioctls/structs should be removed as well, but they are | 253 | /* |
| 228 | still used in tuner-simple.c (TUNER_SET_CONFIG), cx18/ivtv (RESET) and | 254 | * FIXME: these remaining ioctls/structs should be removed as well, but they |
| 229 | v4l2-int-device.h (v4l2_routing). To remove these ioctls some more cleanup | 255 | * are still used in tuner-simple.c (TUNER_SET_CONFIG) and cx18/ivtv (RESET). |
| 230 | is needed in those modules. */ | 256 | * To remove these ioctls some more cleanup is needed in those modules. |
| 257 | * | ||
| 258 | * It doesn't make much sense on documenting them, as what we really want is | ||
| 259 | * to get rid of them. | ||
| 260 | */ | ||
| 231 | 261 | ||
| 232 | /* s_config */ | 262 | /* s_config */ |
| 233 | struct v4l2_priv_tun_config { | 263 | struct v4l2_priv_tun_config { |
| @@ -236,32 +266,79 @@ struct v4l2_priv_tun_config { | |||
| 236 | }; | 266 | }; |
| 237 | #define TUNER_SET_CONFIG _IOW('d', 92, struct v4l2_priv_tun_config) | 267 | #define TUNER_SET_CONFIG _IOW('d', 92, struct v4l2_priv_tun_config) |
| 238 | 268 | ||
| 239 | #define VIDIOC_INT_RESET _IOW ('d', 102, u32) | 269 | #define VIDIOC_INT_RESET _IOW ('d', 102, u32) |
| 240 | |||
| 241 | struct v4l2_routing { | ||
| 242 | u32 input; | ||
| 243 | u32 output; | ||
| 244 | }; | ||
| 245 | 270 | ||
| 246 | /* ------------------------------------------------------------------------- */ | 271 | /* ------------------------------------------------------------------------- */ |
| 247 | 272 | ||
| 248 | /* Miscellaneous helper functions */ | 273 | /* Miscellaneous helper functions */ |
| 249 | 274 | ||
| 250 | void v4l_bound_align_image(unsigned int *w, unsigned int wmin, | 275 | /** |
| 276 | * v4l_bound_align_image - adjust video dimensions according to | ||
| 277 | * a given constraints. | ||
| 278 | * | ||
| 279 | * @width: pointer to width that will be adjusted if needed. | ||
| 280 | * @wmin: minimum width. | ||
| 281 | * @wmax: maximum width. | ||
| 282 | * @walign: least significant bit on width. | ||
| 283 | * @height: pointer to height that will be adjusted if needed. | ||
| 284 | * @hmin: minimum height. | ||
| 285 | * @hmax: maximum height. | ||
| 286 | * @halign: least significant bit on width. | ||
| 287 | * @salign: least significant bit for the image size (e. g. | ||
| 288 | * :math:`width * height`). | ||
| 289 | * | ||
| 290 | * Clip an image to have @width between @wmin and @wmax, and @height between | ||
| 291 | * @hmin and @hmax, inclusive. | ||
| 292 | * | ||
| 293 | * Additionally, the @width will be a multiple of :math:`2^{walign}`, | ||
| 294 | * the @height will be a multiple of :math:`2^{halign}`, and the overall | ||
| 295 | * size :math:`width * height` will be a multiple of :math:`2^{salign}`. | ||
| 296 | * | ||
| 297 | * .. note:: | ||
| 298 | * | ||
| 299 | * #. The clipping rectangle may be shrunk or enlarged to fit the alignment | ||
| 300 | * constraints. | ||
| 301 | * #. @wmax must not be smaller than @wmin. | ||
| 302 | * #. @hmax must not be smaller than @hmin. | ||
| 303 | * #. The alignments must not be so high there are no possible image | ||
| 304 | * sizes within the allowed bounds. | ||
| 305 | * #. @wmin and @hmin must be at least 1 (don't use 0). | ||
| 306 | * #. For @walign, @halign and @salign, if you don't care about a certain | ||
| 307 | * alignment, specify ``0``, as :math:`2^0 = 1` and one byte alignment | ||
| 308 | * is equivalent to no alignment. | ||
| 309 | * #. If you only want to adjust downward, specify a maximum that's the | ||
| 310 | * same as the initial value. | ||
| 311 | */ | ||
| 312 | void v4l_bound_align_image(unsigned int *width, unsigned int wmin, | ||
| 251 | unsigned int wmax, unsigned int walign, | 313 | unsigned int wmax, unsigned int walign, |
| 252 | unsigned int *h, unsigned int hmin, | 314 | unsigned int *height, unsigned int hmin, |
| 253 | unsigned int hmax, unsigned int halign, | 315 | unsigned int hmax, unsigned int halign, |
| 254 | unsigned int salign); | 316 | unsigned int salign); |
| 255 | 317 | ||
| 256 | struct v4l2_discrete_probe { | 318 | /** |
| 257 | const struct v4l2_frmsize_discrete *sizes; | 319 | * v4l2_find_nearest_format - find the nearest format size among a discrete |
| 258 | int num_sizes; | 320 | * set of resolutions. |
| 259 | }; | 321 | * |
| 260 | 322 | * @sizes: array of &struct v4l2_frmsize_discrete image sizes. | |
| 261 | const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( | 323 | * @num_sizes: length of @sizes array. |
| 262 | const struct v4l2_discrete_probe *probe, | 324 | * @width: desired width. |
| 263 | s32 width, s32 height); | 325 | * @height: desired height. |
| 326 | * | ||
| 327 | * Finds the closest resolution to minimize the width and height differences | ||
| 328 | * between what requested and the supported resolutions. | ||
| 329 | */ | ||
| 330 | const struct v4l2_frmsize_discrete * | ||
| 331 | v4l2_find_nearest_format(const struct v4l2_frmsize_discrete *sizes, | ||
| 332 | const size_t num_sizes, | ||
| 333 | s32 width, s32 height); | ||
| 264 | 334 | ||
| 335 | /** | ||
| 336 | * v4l2_get_timestamp - helper routine to get a timestamp to be used when | ||
| 337 | * filling streaming metadata. Internally, it uses ktime_get_ts(), | ||
| 338 | * which is the recommended way to get it. | ||
| 339 | * | ||
| 340 | * @tv: pointer to &struct timeval to be filled. | ||
| 341 | */ | ||
| 265 | void v4l2_get_timestamp(struct timeval *tv); | 342 | void v4l2_get_timestamp(struct timeval *tv); |
| 266 | 343 | ||
| 267 | #endif /* V4L2_COMMON_H_ */ | 344 | #endif /* V4L2_COMMON_H_ */ |
