1 From 2e0e1d7b493dffe7baa763d499e51ba42f0bad19 Mon Sep 17 00:00:00 2001
2 From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
3 Date: Fri, 29 Sep 2023 17:14:11 +0300
4 Subject: [PATCH] media: rp1: cfe: Add cfe_find_16bit_code() and
5 cfe_find_compressed_code()
7 Add helper functions which, given an mbus code, return the 16-bit
8 remapped mbus code or the compressed mbus code.
10 Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
12 .../media/platform/raspberrypi/rp1_cfe/cfe.c | 40 +++++++++++++++++++
13 .../media/platform/raspberrypi/rp1_cfe/cfe.h | 2 +
14 2 files changed, 42 insertions(+)
16 --- a/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
17 +++ b/drivers/media/platform/raspberrypi/rp1_cfe/cfe.c
18 @@ -473,6 +473,46 @@ const struct cfe_fmt *find_format_by_pix
23 + * Given the mbus code, find the 16 bit remapped code. Returns 0 if no remap
26 +u32 cfe_find_16bit_code(u32 code)
28 + const struct cfe_fmt *cfe_fmt;
30 + cfe_fmt = find_format_by_code(code);
32 + if (!cfe_fmt || !cfe_fmt->remap[CFE_REMAP_16BIT])
35 + cfe_fmt = find_format_by_pix(cfe_fmt->remap[CFE_REMAP_16BIT]);
39 + return cfe_fmt->code;
43 + * Given the mbus code, find the 8 bit compressed code. Returns 0 if no remap
46 +u32 cfe_find_compressed_code(u32 code)
48 + const struct cfe_fmt *cfe_fmt;
50 + cfe_fmt = find_format_by_code(code);
52 + if (!cfe_fmt || !cfe_fmt->remap[CFE_REMAP_COMPRESSED])
55 + cfe_fmt = find_format_by_pix(cfe_fmt->remap[CFE_REMAP_COMPRESSED]);
59 + return cfe_fmt->code;
62 static int cfe_calc_format_size_bpl(struct cfe_device *cfe,
63 const struct cfe_fmt *fmt,
64 struct v4l2_format *f)
65 --- a/drivers/media/platform/raspberrypi/rp1_cfe/cfe.h
66 +++ b/drivers/media/platform/raspberrypi/rp1_cfe/cfe.h
67 @@ -37,5 +37,7 @@ extern const struct v4l2_mbus_framefmt c
69 const struct cfe_fmt *find_format_by_code(u32 code);
70 const struct cfe_fmt *find_format_by_pix(u32 pixelformat);
71 +u32 cfe_find_16bit_code(u32 code);
72 +u32 cfe_find_compressed_code(u32 code);