1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Helper functions for HEVC stateless codecs. 4 */ 5 6 #ifndef _MEDIA_V4L2_HEVC_H 7 #define _MEDIA_V4L2_HEVC_H 8 9 #include <linux/minmax.h> 10 #include <media/v4l2-ctrls.h> 11 12 /** 13 * v4l2_hevc_pps_num_tile_columns - number of HEVC tile columns, bounded 14 * @pps: the V4L2 HEVC PPS control 15 * 16 * Return the number of tile columns (num_tile_columns_minus1 + 1) clamped to 17 * the capacity of column_width_minus1[]. The control validation already 18 * rejects out-of-range counts; this keeps the consuming drivers bounded too. 19 */ 20 static inline unsigned int v4l2_hevc_pps_num_tile_columns(const struct v4l2_ctrl_hevc_pps * pps)21v4l2_hevc_pps_num_tile_columns(const struct v4l2_ctrl_hevc_pps *pps) 22 { 23 return min_t(unsigned int, pps->num_tile_columns_minus1 + 1, 24 ARRAY_SIZE(pps->column_width_minus1)); 25 } 26 27 /** 28 * v4l2_hevc_pps_num_tile_rows - number of HEVC tile rows, bounded 29 * @pps: the V4L2 HEVC PPS control 30 * 31 * Return the number of tile rows (num_tile_rows_minus1 + 1) clamped to the 32 * capacity of row_height_minus1[]. 33 */ 34 static inline unsigned int v4l2_hevc_pps_num_tile_rows(const struct v4l2_ctrl_hevc_pps * pps)35v4l2_hevc_pps_num_tile_rows(const struct v4l2_ctrl_hevc_pps *pps) 36 { 37 return min_t(unsigned int, pps->num_tile_rows_minus1 + 1, 38 ARRAY_SIZE(pps->row_height_minus1)); 39 } 40 41 #endif /* _MEDIA_V4L2_HEVC_H */ 42