63 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * camss-format.h4 *5 * Qualcomm MSM Camera Subsystem - Format helpers6 *7 * Copyright (c) 2023, The Linux Foundation. All rights reserved.8 * Copyright (c) 2023 Qualcomm Technologies, Inc.9 */10#ifndef __CAMSS_FORMAT_H__11#define __CAMSS_FORMAT_H__12 13#include <linux/types.h>14 15#define PER_PLANE_DATA(plane, h_fract_num, h_fract_den, v_fract_num, v_fract_den, _bpp) \16 .hsub[(plane)].numerator = (h_fract_num), \17 .hsub[(plane)].denominator = (h_fract_den), \18 .vsub[(plane)].numerator = (v_fract_num), \19 .vsub[(plane)].denominator = (v_fract_den), \20 .bpp[(plane)] = (_bpp)21 22/*23 * struct fract - Represents a fraction24 * @numerator: Store the numerator part of the fraction25 * @denominator: Store the denominator part of the fraction26 */27struct fract {28 u8 numerator;29 u8 denominator;30};31 32/*33 * struct camss_format_info - ISP media bus format information34 * @code: V4L2 media bus format code35 * @mbus_bpp: Media bus bits per pixel36 * @pixelformat: V4L2 pixel format FCC identifier37 * @planes: Number of planes38 * @hsub: Horizontal subsampling (for each plane)39 * @vsub: Vertical subsampling (for each plane)40 * @bpp: Bits per pixel when stored in memory (for each plane)41 */42struct camss_format_info {43 u32 code;44 u32 mbus_bpp;45 u32 pixelformat;46 u8 planes;47 struct fract hsub[3];48 struct fract vsub[3];49 unsigned int bpp[3];50};51 52struct camss_formats {53 unsigned int nformats;54 const struct camss_format_info *formats;55};56 57u8 camss_format_get_bpp(const struct camss_format_info *formats, unsigned int nformats, u32 code);58u32 camss_format_find_code(u32 *code, unsigned int n_code, unsigned int index, u32 req_code);59int camss_format_find_format(u32 code, u32 pixelformat, const struct camss_format_info *formats,60 unsigned int nformats);61 62#endif /* __CAMSS_FORMAT_H__ */63