diff options
Diffstat (limited to 'include/media/v4l2-common.h')
-rw-r--r-- | include/media/v4l2-common.h | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 150ee16ebd81..1bdaea248089 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -175,7 +175,8 @@ struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, * * @sd: pointer to &struct v4l2_subdev * @client: pointer to struct i2c_client - * @devname: the name of the device; if NULL, the I²C device's name will be used + * @devname: the name of the device; if NULL, the I²C device drivers's name + * will be used * @postfix: sub-device specific string to put right after the I²C device name; * may be NULL */ @@ -519,6 +520,31 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat, int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat, u32 width, u32 height); +/** + * v4l2_get_link_freq - Get link rate from transmitter + * + * @handler: The transmitter's control handler + * @mul: The multiplier between pixel rate and link frequency. Bits per pixel on + * D-PHY, samples per clock on parallel. 0 otherwise. + * @div: The divisor between pixel rate and link frequency. Number of data lanes + * times two on D-PHY, 1 on parallel. 0 otherwise. + * + * This function is intended for obtaining the link frequency from the + * transmitter sub-devices. It returns the link rate, either from the + * V4L2_CID_LINK_FREQ control implemented by the transmitter, or value + * calculated based on the V4L2_CID_PIXEL_RATE implemented by the transmitter. + * + * Returns link frequency on success, otherwise a negative error code: + * -ENOENT: Link frequency or pixel rate control not found + * -EINVAL: Invalid link frequency value + */ +s64 v4l2_get_link_freq(struct v4l2_ctrl_handler *handler, unsigned int mul, + unsigned int div); + +void v4l2_simplify_fraction(u32 *numerator, u32 *denominator, + unsigned int n_terms, unsigned int threshold); +u32 v4l2_fraction_to_interval(u32 numerator, u32 denominator); + static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf) { /* @@ -539,4 +565,33 @@ static inline void v4l2_buffer_set_timestamp(struct v4l2_buffer *buf, buf->timestamp.tv_usec = ts.tv_nsec / NSEC_PER_USEC; } +static inline bool v4l2_is_colorspace_valid(__u32 colorspace) +{ + return colorspace > V4L2_COLORSPACE_DEFAULT && + colorspace < V4L2_COLORSPACE_LAST; +} + +static inline bool v4l2_is_xfer_func_valid(__u32 xfer_func) +{ + return xfer_func > V4L2_XFER_FUNC_DEFAULT && + xfer_func < V4L2_XFER_FUNC_LAST; +} + +static inline bool v4l2_is_ycbcr_enc_valid(__u8 ycbcr_enc) +{ + return ycbcr_enc > V4L2_YCBCR_ENC_DEFAULT && + ycbcr_enc < V4L2_YCBCR_ENC_LAST; +} + +static inline bool v4l2_is_hsv_enc_valid(__u8 hsv_enc) +{ + return hsv_enc == V4L2_HSV_ENC_180 || hsv_enc == V4L2_HSV_ENC_256; +} + +static inline bool v4l2_is_quant_valid(__u8 quantization) +{ + return quantization == V4L2_QUANTIZATION_FULL_RANGE || + quantization == V4L2_QUANTIZATION_LIM_RANGE; +} + #endif /* V4L2_COMMON_H_ */ |