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