summaryrefslogtreecommitdiff
path: root/drivers/media/platform/qcom/camss/camss-format.h
blob: 923a48c9c3fb6d0e9c0c1f087509f70f68049e4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * camss-format.h
 *
 * Qualcomm MSM Camera Subsystem - Format helpers
 *
 * Copyright (c) 2023, The Linux Foundation. All rights reserved.
 * Copyright (c) 2023 Qualcomm Technologies, Inc.
 */
#ifndef __CAMSS_FORMAT_H__
#define __CAMSS_FORMAT_H__

#include <linux/types.h>

#define PER_PLANE_DATA(plane, h_fract_num, h_fract_den, v_fract_num, v_fract_den, _bpp)         \
	.hsub[(plane)].numerator	= (h_fract_num),                                        \
	.hsub[(plane)].denominator	= (h_fract_den),                                        \
	.vsub[(plane)].numerator	= (v_fract_num),                                        \
	.vsub[(plane)].denominator	= (v_fract_den),                                        \
	.bpp[(plane)]			= (_bpp)

/*
 * struct fract - Represents a fraction
 * @numerator: Store the numerator part of the fraction
 * @denominator: Store the denominator part of the fraction
 */
struct fract {
	u8 numerator;
	u8 denominator;
};

/*
 * struct camss_format_info - ISP media bus format information
 * @code: V4L2 media bus format code
 * @mbus_bpp: Media bus bits per pixel
 * @pixelformat: V4L2 pixel format FCC identifier
 * @planes: Number of planes
 * @hsub: Horizontal subsampling (for each plane)
 * @vsub: Vertical subsampling (for each plane)
 * @bpp: Bits per pixel when stored in memory (for each plane)
 */
struct camss_format_info {
	u32 code;
	u32 mbus_bpp;
	u32 pixelformat;
	u8 planes;
	struct fract hsub[3];
	struct fract vsub[3];
	unsigned int bpp[3];
};

struct camss_formats {
	unsigned int nformats;
	const struct camss_format_info *formats;
};

u8 camss_format_get_bpp(const struct camss_format_info *formats, unsigned int nformats, u32 code);
u32 camss_format_find_code(u32 *code, unsigned int n_code, unsigned int index, u32 req_code);
int camss_format_find_format(u32 code, u32 pixelformat, const struct camss_format_info *formats,
			     unsigned int nformats);

#endif /* __CAMSS_FORMAT_H__ */