The different resources required for different camss soc versions are
split in to two groups:
1. Camss device related. In this group are all resources described
in the device tree, clocks, regulators etc.
2. Sub-device specific resources. In the initialization
of the each sub-device, the version of camss is passed.
Based on this version the sub-device adds: hw layer support,
per pad formats, number of dma's etc.
The code for "1" group lives in camss.c. However the "2" group
is spread across all sub-device implementations including video device.
This kind of separation is not very convenient when adding new camss soc
version. The reason is that you need to add support in all sub-device
implementations.
There were some improvements in this direction where some of the
hw version related definitions were moved in to the "1". One
example is attaching of the hw operations.
This series aim to improve the things more and add additional definitions
in to the "1".
What is included:
- Remove all format definitions from camss video. The will be passed
by the parent sub-device
- Make camss generic format definition mapping, containing mbus to
v4l2 mapping, mbus bpp and other required fields used by the
sub-device and video node.
- Add per sub-device type union in the resources, different
sub-devices are using different resources, as an example: is_lite flag.
- Move camss link operation in to the resources. Currently one
function supports different topologies depending of the number
of devices. As hw version support increases this is not good
way of supporting different topologies.
- Add parent device ops in to the resources. This resolves
inter-dependencies of vfe and csid. Csid requests the clocks
regulators etc from parent device instead calling directly vfe
functions.
- Some cleanups in csid code for split the configuration of
RX and testgen and RDI.
Changes in V3:
- Incorporate missing changes in resources reported and fixed by
Bryan O'Donoghue <[email protected]> taken from the branch:
https://git.codelinaro.org/bryan.odonoghue/kernel/-/tree/sc8280xp-6.9-rc1-camss-resource-change-verification?ref_type=heads
- Added missing signed-off to the changes submitted by me.
Changes in V2:
- Rebased on top of sc8280xp v6.
- The change "Designate lite subdevices in resources" was dropped,
it was already merged in previous series.
Atanas Filipov (1):
media: qcom: camss: Decompose register and link operations
Milen Mitkov (2):
media: qcom: camss: Split testgen, RDI and RX for CSID 170
media: qcom: camss: Decouple VFE from CSID
Radoslav Tsvetkov (5):
media: qcom: camss: Add per sub-device type resources
media: qcom: camss: Attach formats to VFE resources
media: qcom: camss: Attach formats to CSID resources
media: qcom: camss: Attach formats to CSIPHY resources
media: qcom: camss: Move format related functions
drivers/media/platform/qcom/camss/Makefile | 1 +
.../platform/qcom/camss/camss-csid-4-1.c | 132 +---
.../platform/qcom/camss/camss-csid-4-7.c | 160 +---
.../platform/qcom/camss/camss-csid-gen2.c | 410 ++++------
.../media/platform/qcom/camss/camss-csid.c | 512 +++++++++++-
.../media/platform/qcom/camss/camss-csid.h | 32 +-
.../media/platform/qcom/camss/camss-csiphy.c | 74 +-
.../media/platform/qcom/camss/camss-csiphy.h | 23 +-
.../media/platform/qcom/camss/camss-format.c | 98 +++
.../media/platform/qcom/camss/camss-format.h | 67 ++
.../media/platform/qcom/camss/camss-vfe-17x.c | 10 +-
.../media/platform/qcom/camss/camss-vfe-4-1.c | 4 +-
.../media/platform/qcom/camss/camss-vfe-4-7.c | 6 +-
.../media/platform/qcom/camss/camss-vfe-4-8.c | 6 +-
.../platform/qcom/camss/camss-vfe-gen1.c | 8 +-
drivers/media/platform/qcom/camss/camss-vfe.c | 483 +++++++-----
drivers/media/platform/qcom/camss/camss-vfe.h | 22 +-
.../media/platform/qcom/camss/camss-video.c | 295 +------
.../media/platform/qcom/camss/camss-video.h | 5 +-
drivers/media/platform/qcom/camss/camss.c | 729 +++++++++++++-----
drivers/media/platform/qcom/camss/camss.h | 28 +-
21 files changed, 1767 insertions(+), 1338 deletions(-)
create mode 100644 drivers/media/platform/qcom/camss/camss-format.c
create mode 100644 drivers/media/platform/qcom/camss/camss-format.h
--
2.17.1
From: Radoslav Tsvetkov <[email protected]>
Move out the format related helper functions from vfe and video in a
separate file. The goal here is to create a format API.
Signed-off-by: Radoslav Tsvetkov <[email protected]>
Signed-off-by: Gjorgji Rosikopulos <[email protected]>
---
drivers/media/platform/qcom/camss/Makefile | 1 +
.../media/platform/qcom/camss/camss-format.c | 98 +++++++++++++++++++
.../media/platform/qcom/camss/camss-format.h | 5 +
drivers/media/platform/qcom/camss/camss-vfe.c | 86 +++++-----------
.../media/platform/qcom/camss/camss-video.c | 26 +----
5 files changed, 128 insertions(+), 88 deletions(-)
create mode 100644 drivers/media/platform/qcom/camss/camss-format.c
diff --git a/drivers/media/platform/qcom/camss/Makefile b/drivers/media/platform/qcom/camss/Makefile
index 0d4389ab312d..e636968a1126 100644
--- a/drivers/media/platform/qcom/camss/Makefile
+++ b/drivers/media/platform/qcom/camss/Makefile
@@ -19,5 +19,6 @@ qcom-camss-objs += \
camss-vfe-gen1.o \
camss-vfe.o \
camss-video.o \
+ camss-format.o \
obj-$(CONFIG_VIDEO_QCOM_CAMSS) += qcom-camss.o
diff --git a/drivers/media/platform/qcom/camss/camss-format.c b/drivers/media/platform/qcom/camss/camss-format.c
new file mode 100644
index 000000000000..6279cb099625
--- /dev/null
+++ b/drivers/media/platform/qcom/camss/camss-format.c
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (c) 2023, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Technologies, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/bug.h>
+#include <linux/errno.h>
+
+#include "camss-format.h"
+
+/*
+ * camss_format_get_bpp - Map media bus format to bits per pixel
+ * @formats: supported media bus formats array
+ * @nformats: size of @formats array
+ * @code: media bus format code
+ *
+ * Return number of bits per pixel
+ */
+u8 camss_format_get_bpp(const struct camss_format_info *formats, unsigned int nformats, u32 code)
+{
+ unsigned int i;
+
+ for (i = 0; i < nformats; i++)
+ if (code == formats[i].code)
+ return formats[i].mbus_bpp;
+
+ WARN(1, "Unknown format\n");
+
+ return formats[0].mbus_bpp;
+}
+
+/*
+ * camss_format_find_code - Find a format code in an array
+ * @code: a pointer to media bus format codes array
+ * @n_code: size of @code array
+ * @index: index of code in the array
+ * @req_code: required code
+ *
+ * Return media bus format code
+ */
+u32 camss_format_find_code(u32 *code, unsigned int n_code, unsigned int index, u32 req_code)
+{
+ int i;
+
+ if (!req_code && index >= n_code)
+ return 0;
+
+ for (i = 0; i < n_code; i++) {
+ if (req_code) {
+ if (req_code == code[i])
+ return req_code;
+ } else {
+ if (i == index)
+ return code[i];
+ }
+ }
+
+ return code[0];
+}
+
+/*
+ * camss_format_find_format - Find a format in an array
+ * @code: media bus format code
+ * @pixelformat: V4L2 pixel format FCC identifier
+ * @formats: a pointer to formats array
+ * @nformats: size of @formats array
+ *
+ * Return index of a format or a negative error code otherwise
+ */
+int camss_format_find_format(u32 code, u32 pixelformat, const struct camss_format_info *formats,
+ unsigned int nformats)
+{
+ int i;
+
+ for (i = 0; i < nformats; i++) {
+ if (formats[i].code == code &&
+ formats[i].pixelformat == pixelformat)
+ return i;
+ }
+
+ for (i = 0; i < nformats; i++) {
+ if (formats[i].code == code)
+ return i;
+ }
+
+ WARN_ON(1);
+
+ return -EINVAL;
+}
diff --git a/drivers/media/platform/qcom/camss/camss-format.h b/drivers/media/platform/qcom/camss/camss-format.h
index bfbc761bd46c..86b5790e343d 100644
--- a/drivers/media/platform/qcom/camss/camss-format.h
+++ b/drivers/media/platform/qcom/camss/camss-format.h
@@ -59,4 +59,9 @@ struct camss_formats {
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__ */
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index 2d5a64c055f1..83c5a36d071f 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -278,48 +278,6 @@ const struct camss_formats vfe_formats_pix_845 = {
.formats = formats_rdi_845
};
-/*
- * vfe_get_bpp - map media bus format to bits per pixel
- * @formats: supported media bus formats array
- * @nformats: size of @formats array
- * @code: media bus format code
- *
- * Return number of bits per pixel
- */
-static u8 vfe_get_bpp(const struct camss_format_info *formats,
- unsigned int nformats, u32 code)
-{
- unsigned int i;
-
- for (i = 0; i < nformats; i++)
- if (code == formats[i].code)
- return formats[i].mbus_bpp;
-
- WARN(1, "Unknown format\n");
-
- return formats[0].mbus_bpp;
-}
-
-static u32 vfe_find_code(u32 *code, unsigned int n_code,
- unsigned int index, u32 req_code)
-{
- int i;
-
- if (!req_code && (index >= n_code))
- return 0;
-
- for (i = 0; i < n_code; i++)
- if (req_code) {
- if (req_code == code[i])
- return req_code;
- } else {
- if (i == index)
- return code[i];
- }
-
- return code[0];
-}
-
static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
unsigned int index, u32 src_req_code)
{
@@ -335,8 +293,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
MEDIA_BUS_FMT_YUYV8_1_5X8,
};
- return vfe_find_code(src_code, ARRAY_SIZE(src_code),
- index, src_req_code);
+ return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
+ index, src_req_code);
}
case MEDIA_BUS_FMT_YVYU8_1X16:
{
@@ -345,8 +303,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
MEDIA_BUS_FMT_YVYU8_1_5X8,
};
- return vfe_find_code(src_code, ARRAY_SIZE(src_code),
- index, src_req_code);
+ return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
+ index, src_req_code);
}
case MEDIA_BUS_FMT_UYVY8_1X16:
{
@@ -355,8 +313,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
MEDIA_BUS_FMT_UYVY8_1_5X8,
};
- return vfe_find_code(src_code, ARRAY_SIZE(src_code),
- index, src_req_code);
+ return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
+ index, src_req_code);
}
case MEDIA_BUS_FMT_VYUY8_1X16:
{
@@ -365,8 +323,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
MEDIA_BUS_FMT_VYUY8_1_5X8,
};
- return vfe_find_code(src_code, ARRAY_SIZE(src_code),
- index, src_req_code);
+ return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
+ index, src_req_code);
}
default:
if (index > 0)
@@ -391,8 +349,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
MEDIA_BUS_FMT_YUYV8_1_5X8,
};
- return vfe_find_code(src_code, ARRAY_SIZE(src_code),
- index, src_req_code);
+ return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
+ index, src_req_code);
}
case MEDIA_BUS_FMT_YVYU8_1X16:
{
@@ -404,8 +362,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
MEDIA_BUS_FMT_YVYU8_1_5X8,
};
- return vfe_find_code(src_code, ARRAY_SIZE(src_code),
- index, src_req_code);
+ return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
+ index, src_req_code);
}
case MEDIA_BUS_FMT_UYVY8_1X16:
{
@@ -417,8 +375,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
MEDIA_BUS_FMT_UYVY8_1_5X8,
};
- return vfe_find_code(src_code, ARRAY_SIZE(src_code),
- index, src_req_code);
+ return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
+ index, src_req_code);
}
case MEDIA_BUS_FMT_VYUY8_1X16:
{
@@ -430,8 +388,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
MEDIA_BUS_FMT_VYUY8_1_5X8,
};
- return vfe_find_code(src_code, ARRAY_SIZE(src_code),
- index, src_req_code);
+ return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
+ index, src_req_code);
}
default:
if (index > 0)
@@ -714,9 +672,9 @@ static int vfe_set_clock_rates(struct vfe_device *vfe)
} else {
struct vfe_line *l = &vfe->line[j];
- bpp = vfe_get_bpp(l->formats,
- l->nformats,
- l->fmt[MSM_VFE_PAD_SINK].code);
+ bpp = camss_format_get_bpp(l->formats,
+ l->nformats,
+ l->fmt[MSM_VFE_PAD_SINK].code);
tmp = pixel_clock[j] * bpp / 64;
}
@@ -795,9 +753,9 @@ static int vfe_check_clock_rates(struct vfe_device *vfe)
} else {
struct vfe_line *l = &vfe->line[j];
- bpp = vfe_get_bpp(l->formats,
- l->nformats,
- l->fmt[MSM_VFE_PAD_SINK].code);
+ bpp = camss_format_get_bpp(l->formats,
+ l->nformats,
+ l->fmt[MSM_VFE_PAD_SINK].code);
tmp = pixel_clock[j] * bpp / 64;
}
diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index cd13a432e291..00b10dda3615 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -28,27 +28,6 @@
* Helper functions
*/
-static int video_find_format(u32 code, u32 pixelformat,
- const struct camss_format_info *formats,
- unsigned int nformats)
-{
- int i;
-
- for (i = 0; i < nformats; i++) {
- if (formats[i].code == code &&
- formats[i].pixelformat == pixelformat)
- return i;
- }
-
- for (i = 0; i < nformats; i++)
- if (formats[i].code == code)
- return i;
-
- WARN_ON(1);
-
- return -EINVAL;
-}
-
/*
* video_mbus_to_pix_mp - Convert v4l2_mbus_framefmt to v4l2_pix_format_mplane
* @mbus: v4l2_mbus_framefmt format (input)
@@ -121,9 +100,8 @@ static int video_get_subdev_format(struct camss_video *video,
if (ret)
return ret;
- ret = video_find_format(fmt.format.code,
- format->fmt.pix_mp.pixelformat,
- video->formats, video->nformats);
+ ret = camss_format_find_format(fmt.format.code, format->fmt.pix_mp.pixelformat,
+ video->formats, video->nformats);
if (ret < 0)
return ret;
--
2.17.1
From: Radoslav Tsvetkov <[email protected]>
Video node formats have direct dependency by the sub-device pad formats.
Remove dependency for SoC version and move format definitions in device
which creates video node.
This commit attaches a struct to the VFE resources that holds format
description, so it is much easier to assign them to the video node.
No need to use a switch-case.
NOTE: The mbus_bpp is used to calculate the clock rates and is different
from bpp which is the bits per pixel written to memory. We need to keep
both values to not break the calcualtions.
Signed-off-by: Radoslav Tsvetkov <[email protected]>
Signed-off-by: Gjorgji Rosikopulos <[email protected]>
---
.../media/platform/qcom/camss/camss-format.h | 62 +++
drivers/media/platform/qcom/camss/camss-vfe.c | 359 ++++++++++++------
drivers/media/platform/qcom/camss/camss-vfe.h | 11 +-
.../media/platform/qcom/camss/camss-video.c | 269 +------------
.../media/platform/qcom/camss/camss-video.h | 5 +-
drivers/media/platform/qcom/camss/camss.c | 80 +++-
drivers/media/platform/qcom/camss/camss.h | 1 +
7 files changed, 383 insertions(+), 404 deletions(-)
create mode 100644 drivers/media/platform/qcom/camss/camss-format.h
diff --git a/drivers/media/platform/qcom/camss/camss-format.h b/drivers/media/platform/qcom/camss/camss-format.h
new file mode 100644
index 000000000000..bfbc761bd46c
--- /dev/null
+++ b/drivers/media/platform/qcom/camss/camss-format.h
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (c) 2023, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Technologies, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#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)
+
+#ifndef __CAMSS_FORMAT_H__
+#define __CAMSS_FORMAT_H__
+
+#include <linux/types.h>
+
+/*
+ * 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;
+};
+
+#endif /* __CAMSS_FORMAT_H__ */
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index 459c70a4b319..2d5a64c055f1 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -32,96 +32,250 @@
#define SCALER_RATIO_MAX 16
-struct vfe_format {
- u32 code;
- u8 bpp;
+static const struct camss_format_info formats_rdi_8x16[] = {
+ { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_SBGGR8_1X8, 8, V4L2_PIX_FMT_SBGGR8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SGBRG8_1X8, 8, V4L2_PIX_FMT_SGBRG8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SGRBG8_1X8, 8, V4L2_PIX_FMT_SGRBG8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SRGGB8_1X8, 8, V4L2_PIX_FMT_SRGGB8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SBGGR10_1X10, 10, V4L2_PIX_FMT_SBGGR10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SGBRG10_1X10, 10, V4L2_PIX_FMT_SGBRG10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SGRBG10_1X10, 10, V4L2_PIX_FMT_SGRBG10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SRGGB10_1X10, 10, V4L2_PIX_FMT_SRGGB10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SBGGR12_1X12, 12, V4L2_PIX_FMT_SBGGR12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SGBRG12_1X12, 12, V4L2_PIX_FMT_SGBRG12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SGRBG12_1X12, 12, V4L2_PIX_FMT_SGRBG12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SRGGB12_1X12, 12, V4L2_PIX_FMT_SRGGB12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_Y10_1X10, 10, V4L2_PIX_FMT_Y10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+};
+
+static const struct camss_format_info formats_rdi_8x96[] = {
+ { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_SBGGR8_1X8, 8, V4L2_PIX_FMT_SBGGR8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SGBRG8_1X8, 8, V4L2_PIX_FMT_SGBRG8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SGRBG8_1X8, 8, V4L2_PIX_FMT_SGRBG8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SRGGB8_1X8, 8, V4L2_PIX_FMT_SRGGB8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SBGGR10_1X10, 10, V4L2_PIX_FMT_SBGGR10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SGBRG10_1X10, 10, V4L2_PIX_FMT_SGBRG10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SGRBG10_1X10, 10, V4L2_PIX_FMT_SGRBG10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SRGGB10_1X10, 10, V4L2_PIX_FMT_SRGGB10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_SBGGR10, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_SBGGR12_1X12, 12, V4L2_PIX_FMT_SBGGR12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SGBRG12_1X12, 12, V4L2_PIX_FMT_SGBRG12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SGRBG12_1X12, 12, V4L2_PIX_FMT_SGRBG12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SRGGB12_1X12, 12, V4L2_PIX_FMT_SRGGB12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SBGGR14_1X14, 14, V4L2_PIX_FMT_SBGGR14P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
+ { MEDIA_BUS_FMT_SGBRG14_1X14, 14, V4L2_PIX_FMT_SGBRG14P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
+ { MEDIA_BUS_FMT_SGRBG14_1X14, 14, V4L2_PIX_FMT_SGRBG14P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
+ { MEDIA_BUS_FMT_SRGGB14_1X14, 14, V4L2_PIX_FMT_SRGGB14P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
+ { MEDIA_BUS_FMT_Y10_1X10, 10, V4L2_PIX_FMT_Y10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_Y10, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+};
+
+static const struct camss_format_info formats_rdi_845[] = {
+ { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_SBGGR8_1X8, 8, V4L2_PIX_FMT_SBGGR8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SGBRG8_1X8, 8, V4L2_PIX_FMT_SGBRG8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SGRBG8_1X8, 8, V4L2_PIX_FMT_SGRBG8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SRGGB8_1X8, 8, V4L2_PIX_FMT_SRGGB8, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_SBGGR10_1X10, 10, V4L2_PIX_FMT_SBGGR10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SGBRG10_1X10, 10, V4L2_PIX_FMT_SGBRG10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SGRBG10_1X10, 10, V4L2_PIX_FMT_SGRBG10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SRGGB10_1X10, 10, V4L2_PIX_FMT_SRGGB10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_SBGGR10, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_SBGGR12_1X12, 12, V4L2_PIX_FMT_SBGGR12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SGBRG12_1X12, 12, V4L2_PIX_FMT_SGBRG12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SGRBG12_1X12, 12, V4L2_PIX_FMT_SGRBG12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SRGGB12_1X12, 12, V4L2_PIX_FMT_SRGGB12P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
+ { MEDIA_BUS_FMT_SBGGR14_1X14, 14, V4L2_PIX_FMT_SBGGR14P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
+ { MEDIA_BUS_FMT_SGBRG14_1X14, 14, V4L2_PIX_FMT_SGBRG14P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
+ { MEDIA_BUS_FMT_SGRBG14_1X14, 14, V4L2_PIX_FMT_SGRBG14P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
+ { MEDIA_BUS_FMT_SRGGB14_1X14, 14, V4L2_PIX_FMT_SRGGB14P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
+ { MEDIA_BUS_FMT_Y8_1X8, 8, V4L2_PIX_FMT_GREY, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
+ { MEDIA_BUS_FMT_Y10_1X10, 10, V4L2_PIX_FMT_Y10P, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
+ { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_Y10, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+};
+
+static const struct camss_format_info formats_pix_8x16[] = {
+ { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+};
+
+static const struct camss_format_info formats_pix_8x96[] = {
+ { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
+ PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
+ { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
+ { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+ { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
+ PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
+};
+
+const struct camss_formats vfe_formats_rdi_8x16 = {
+ .nformats = ARRAY_SIZE(formats_rdi_8x16),
+ .formats = formats_rdi_8x16
};
-static const struct vfe_format formats_rdi_8x16[] = {
- { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
- { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
- { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
- { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
- { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
- { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
- { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
- { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
- { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
- { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
- { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
- { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
- { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
- { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
- { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
- { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
- { MEDIA_BUS_FMT_Y10_1X10, 10 },
+const struct camss_formats vfe_formats_pix_8x16 = {
+ .nformats = ARRAY_SIZE(formats_pix_8x16),
+ .formats = formats_pix_8x16
};
-static const struct vfe_format formats_pix_8x16[] = {
- { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
- { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
- { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
- { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
+const struct camss_formats vfe_formats_rdi_8x96 = {
+ .nformats = ARRAY_SIZE(formats_rdi_8x96),
+ .formats = formats_rdi_8x96
};
-static const struct vfe_format formats_rdi_8x96[] = {
- { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
- { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
- { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
- { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
- { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
- { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
- { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
- { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
- { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
- { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
- { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
- { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
- { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16 },
- { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
- { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
- { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
- { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
- { MEDIA_BUS_FMT_SBGGR14_1X14, 14 },
- { MEDIA_BUS_FMT_SGBRG14_1X14, 14 },
- { MEDIA_BUS_FMT_SGRBG14_1X14, 14 },
- { MEDIA_BUS_FMT_SRGGB14_1X14, 14 },
- { MEDIA_BUS_FMT_Y10_1X10, 10 },
- { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16 },
+const struct camss_formats vfe_formats_pix_8x96 = {
+ .nformats = ARRAY_SIZE(formats_pix_8x96),
+ .formats = formats_pix_8x96
};
-static const struct vfe_format formats_pix_8x96[] = {
- { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
- { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
- { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
- { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
+const struct camss_formats vfe_formats_rdi_845 = {
+ .nformats = ARRAY_SIZE(formats_rdi_845),
+ .formats = formats_rdi_845
};
-static const struct vfe_format formats_rdi_845[] = {
- { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
- { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
- { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
- { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
- { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
- { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
- { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
- { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
- { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
- { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
- { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
- { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
- { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16 },
- { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
- { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
- { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
- { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
- { MEDIA_BUS_FMT_SBGGR14_1X14, 14 },
- { MEDIA_BUS_FMT_SGBRG14_1X14, 14 },
- { MEDIA_BUS_FMT_SGRBG14_1X14, 14 },
- { MEDIA_BUS_FMT_SRGGB14_1X14, 14 },
- { MEDIA_BUS_FMT_Y8_1X8, 8 },
- { MEDIA_BUS_FMT_Y10_1X10, 10 },
- { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16 },
+/* TODO: Replace with pix formats */
+const struct camss_formats vfe_formats_pix_845 = {
+ .nformats = ARRAY_SIZE(formats_rdi_845),
+ .formats = formats_rdi_845
};
/*
@@ -132,18 +286,18 @@ static const struct vfe_format formats_rdi_845[] = {
*
* Return number of bits per pixel
*/
-static u8 vfe_get_bpp(const struct vfe_format *formats,
+static u8 vfe_get_bpp(const struct camss_format_info *formats,
unsigned int nformats, u32 code)
{
unsigned int i;
for (i = 0; i < nformats; i++)
if (code == formats[i].code)
- return formats[i].bpp;
+ return formats[i].mbus_bpp;
WARN(1, "Unknown format\n");
- return formats[0].bpp;
+ return formats[0].mbus_bpp;
}
static u32 vfe_find_code(u32 *code, unsigned int n_code,
@@ -1495,32 +1649,12 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
init_completion(&l->output.sof);
init_completion(&l->output.reg_update);
- switch (camss->res->version) {
- case CAMSS_8x16:
- if (i == VFE_LINE_PIX) {
- l->formats = formats_pix_8x16;
- l->nformats = ARRAY_SIZE(formats_pix_8x16);
- } else {
- l->formats = formats_rdi_8x16;
- l->nformats = ARRAY_SIZE(formats_rdi_8x16);
- }
- break;
- case CAMSS_8x96:
- case CAMSS_660:
- if (i == VFE_LINE_PIX) {
- l->formats = formats_pix_8x96;
- l->nformats = ARRAY_SIZE(formats_pix_8x96);
- } else {
- l->formats = formats_rdi_8x96;
- l->nformats = ARRAY_SIZE(formats_rdi_8x96);
- }
- break;
- case CAMSS_845:
- case CAMSS_8250:
- case CAMSS_8280XP:
- l->formats = formats_rdi_845;
- l->nformats = ARRAY_SIZE(formats_rdi_845);
- break;
+ if (i == VFE_LINE_PIX) {
+ l->nformats = res->vfe.formats_pix->nformats;
+ l->formats = res->vfe.formats_pix->formats;
+ } else {
+ l->nformats = res->vfe.formats_rdi->nformats;
+ l->formats = res->vfe.formats_rdi->formats;
}
}
@@ -1684,10 +1818,13 @@ int msm_vfe_register_entities(struct vfe_device *vfe,
video_out->bpl_alignment = 16;
video_out->line_based = 1;
}
+
+ video_out->nformats = vfe->line[i].nformats;
+ video_out->formats = vfe->line[i].formats;
+
snprintf(name, ARRAY_SIZE(name), "%s%d_%s%d",
MSM_VFE_NAME, vfe->id, "video", i);
- ret = msm_video_register(video_out, v4l2_dev, name,
- i == VFE_LINE_PIX ? 1 : 0);
+ ret = msm_video_register(video_out, v4l2_dev, name);
if (ret < 0) {
dev_err(dev, "Failed to register video node: %d\n",
ret);
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h
index 87fc159c48cc..10e2cc3c0b83 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.h
+++ b/drivers/media/platform/qcom/camss/camss-vfe.h
@@ -92,7 +92,7 @@ struct vfe_line {
struct v4l2_rect crop;
struct camss_video video_out;
struct vfe_output output;
- const struct vfe_format *formats;
+ const struct camss_format_info *formats;
unsigned int nformats;
};
@@ -132,6 +132,8 @@ struct vfe_subdev_resources {
bool has_pd;
char *pd_name;
const struct vfe_hw_ops *hw_ops;
+ const struct camss_formats *formats_rdi;
+ const struct camss_formats *formats_pix;
};
struct vfe_device {
@@ -224,6 +226,13 @@ void vfe_pm_domain_off(struct vfe_device *vfe);
*/
int vfe_pm_domain_on(struct vfe_device *vfe);
+extern const struct camss_formats vfe_formats_rdi_8x16;
+extern const struct camss_formats vfe_formats_pix_8x16;
+extern const struct camss_formats vfe_formats_rdi_8x96;
+extern const struct camss_formats vfe_formats_pix_8x96;
+extern const struct camss_formats vfe_formats_rdi_845;
+extern const struct camss_formats vfe_formats_pix_845;
+
extern const struct vfe_hw_ops vfe_ops_4_1;
extern const struct vfe_hw_ops vfe_ops_4_7;
extern const struct vfe_hw_ops vfe_ops_4_8;
diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index 54cd82f74115..cd13a432e291 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -24,244 +24,6 @@
#define CAMSS_FRAME_MAX_HEIGHT_RDI 8191
#define CAMSS_FRAME_MAX_HEIGHT_PIX 4096
-struct fract {
- u8 numerator;
- u8 denominator;
-};
-
-/*
- * struct camss_format_info - ISP media bus format information
- * @code: V4L2 media bus format code
- * @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 pixelformat;
- u8 planes;
- struct fract hsub[3];
- struct fract vsub[3];
- unsigned int bpp[3];
-};
-
-static const struct camss_format_info formats_rdi_8x16[] = {
- { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_PIX_FMT_SBGGR8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_PIX_FMT_SGBRG8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_PIX_FMT_SGRBG8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_PIX_FMT_SRGGB8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
-};
-
-static const struct camss_format_info formats_rdi_8x96[] = {
- { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_PIX_FMT_SBGGR8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_PIX_FMT_SGBRG8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_PIX_FMT_SGRBG8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_PIX_FMT_SRGGB8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_PIX_FMT_SBGGR10, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SBGGR14_1X14, V4L2_PIX_FMT_SBGGR14P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 14 } },
- { MEDIA_BUS_FMT_SGBRG14_1X14, V4L2_PIX_FMT_SGBRG14P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 14 } },
- { MEDIA_BUS_FMT_SGRBG14_1X14, V4L2_PIX_FMT_SGRBG14P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 14 } },
- { MEDIA_BUS_FMT_SRGGB14_1X14, V4L2_PIX_FMT_SRGGB14P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 14 } },
- { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, V4L2_PIX_FMT_Y10, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
-};
-
-static const struct camss_format_info formats_rdi_845[] = {
- { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_PIX_FMT_SBGGR8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_PIX_FMT_SGBRG8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_PIX_FMT_SGRBG8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_PIX_FMT_SRGGB8, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_PIX_FMT_SBGGR10, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 12 } },
- { MEDIA_BUS_FMT_SBGGR14_1X14, V4L2_PIX_FMT_SBGGR14P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 14 } },
- { MEDIA_BUS_FMT_SGBRG14_1X14, V4L2_PIX_FMT_SGBRG14P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 14 } },
- { MEDIA_BUS_FMT_SGRBG14_1X14, V4L2_PIX_FMT_SGRBG14P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 14 } },
- { MEDIA_BUS_FMT_SRGGB14_1X14, V4L2_PIX_FMT_SRGGB14P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 14 } },
- { MEDIA_BUS_FMT_Y8_1X8, V4L2_PIX_FMT_GREY, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 8 } },
- { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 10 } },
- { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, V4L2_PIX_FMT_Y10, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
-};
-
-static const struct camss_format_info formats_pix_8x16[] = {
- { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV12, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV12, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV21, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV21, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV16, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV16, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV16, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV16, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV61, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV61, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV61, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV61, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
-};
-
-static const struct camss_format_info formats_pix_8x96[] = {
- { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV12, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV12, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV21, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV21, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
- { { 1, 1 } }, { { 2, 3 } }, { 8 } },
- { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV16, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV16, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV16, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV16, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV61, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV61, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV61, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV61, 1,
- { { 1, 1 } }, { { 1, 2 } }, { 8 } },
- { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
- { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
- { { 1, 1 } }, { { 1, 1 } }, { 16 } },
-};
-
/* -----------------------------------------------------------------------------
* Helper functions
*/
@@ -968,8 +730,7 @@ static int msm_video_init_format(struct camss_video *video)
* Return 0 on success or a negative error code otherwise
*/
-int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
- const char *name, int is_pix)
+int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, const char *name)
{
struct media_pad *pad = &video->pad;
struct video_device *vdev;
@@ -1006,34 +767,6 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
mutex_init(&video->lock);
- switch (video->camss->res->version) {
- case CAMSS_8x16:
- if (is_pix) {
- video->formats = formats_pix_8x16;
- video->nformats = ARRAY_SIZE(formats_pix_8x16);
- } else {
- video->formats = formats_rdi_8x16;
- video->nformats = ARRAY_SIZE(formats_rdi_8x16);
- }
- break;
- case CAMSS_8x96:
- case CAMSS_660:
- if (is_pix) {
- video->formats = formats_pix_8x96;
- video->nformats = ARRAY_SIZE(formats_pix_8x96);
- } else {
- video->formats = formats_rdi_8x96;
- video->nformats = ARRAY_SIZE(formats_rdi_8x96);
- }
- break;
- case CAMSS_845:
- case CAMSS_8250:
- case CAMSS_8280XP:
- video->formats = formats_rdi_845;
- video->nformats = ARRAY_SIZE(formats_rdi_845);
- break;
- }
-
ret = msm_video_init_format(video);
if (ret < 0) {
dev_err(v4l2_dev->dev, "Failed to init format: %d\n", ret);
diff --git a/drivers/media/platform/qcom/camss/camss-video.h b/drivers/media/platform/qcom/camss/camss-video.h
index bdbae8424140..4f6c0821ead2 100644
--- a/drivers/media/platform/qcom/camss/camss-video.h
+++ b/drivers/media/platform/qcom/camss/camss-video.h
@@ -33,8 +33,6 @@ struct camss_video_ops {
enum vb2_buffer_state state);
};
-struct camss_format_info;
-
struct camss_video {
struct camss *camss;
struct vb2_queue vb2_q;
@@ -52,8 +50,7 @@ struct camss_video {
unsigned int nformats;
};
-int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
- const char *name, int is_pix);
+int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, const char *name);
void msm_video_unregister(struct camss_video *video);
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index e4ae81dc9a15..f3242d2d9807 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -143,7 +143,9 @@ static const struct camss_subdev_resources vfe_res_8x16[] = {
.type = CAMSS_SUBDEV_TYPE_VFE,
.vfe = {
.line_num = 3,
- .hw_ops = &vfe_ops_4_1
+ .hw_ops = &vfe_ops_4_1,
+ .formats_rdi = &vfe_formats_rdi_8x16,
+ .formats_pix = &vfe_formats_pix_8x16
}
}
};
@@ -318,7 +320,9 @@ static const struct camss_subdev_resources vfe_res_8x96[] = {
.vfe = {
.line_num = 3,
.has_pd = true,
- .hw_ops = &vfe_ops_4_7
+ .hw_ops = &vfe_ops_4_7,
+ .formats_rdi = &vfe_formats_rdi_8x96,
+ .formats_pix = &vfe_formats_pix_8x96
}
},
@@ -342,7 +346,9 @@ static const struct camss_subdev_resources vfe_res_8x96[] = {
.vfe = {
.line_num = 3,
.has_pd = true,
- .hw_ops = &vfe_ops_4_7
+ .hw_ops = &vfe_ops_4_7,
+ .formats_rdi = &vfe_formats_rdi_8x96,
+ .formats_pix = &vfe_formats_pix_8x96
}
}
};
@@ -538,7 +544,9 @@ static const struct camss_subdev_resources vfe_res_660[] = {
.vfe = {
.line_num = 3,
.has_pd = true,
- .hw_ops = &vfe_ops_4_8
+ .hw_ops = &vfe_ops_4_8,
+ .formats_rdi = &vfe_formats_rdi_8x96,
+ .formats_pix = &vfe_formats_pix_8x96
}
},
@@ -565,7 +573,9 @@ static const struct camss_subdev_resources vfe_res_660[] = {
.vfe = {
.line_num = 3,
.has_pd = true,
- .hw_ops = &vfe_ops_4_8
+ .hw_ops = &vfe_ops_4_8,
+ .formats_rdi = &vfe_formats_rdi_8x96,
+ .formats_pix = &vfe_formats_pix_8x96
}
}
};
@@ -758,7 +768,9 @@ static const struct camss_subdev_resources vfe_res_845[] = {
.vfe = {
.line_num = 4,
.has_pd = true,
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
@@ -784,7 +796,9 @@ static const struct camss_subdev_resources vfe_res_845[] = {
.vfe = {
.line_num = 4,
.has_pd = true,
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
@@ -809,7 +823,9 @@ static const struct camss_subdev_resources vfe_res_845[] = {
.vfe = {
.is_lite = true,
.line_num = 4,
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
}
};
@@ -985,7 +1001,9 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
.line_num = 3,
.has_pd = true,
.pd_name = "ife0",
- .hw_ops = &vfe_ops_480
+ .hw_ops = &vfe_ops_480,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
/* VFE1 */
@@ -1010,7 +1028,9 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
.line_num = 3,
.has_pd = true,
.pd_name = "ife1",
- .hw_ops = &vfe_ops_480
+ .hw_ops = &vfe_ops_480,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
/* VFE2 (lite) */
@@ -1033,7 +1053,9 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
.vfe = {
.is_lite = true,
.line_num = 4,
- .hw_ops = &vfe_ops_480
+ .hw_ops = &vfe_ops_480,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
/* VFE3 (lite) */
@@ -1056,7 +1078,9 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
.vfe = {
.is_lite = true,
.line_num = 4,
- .hw_ops = &vfe_ops_480
+ .hw_ops = &vfe_ops_480,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
};
@@ -1267,7 +1291,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
.vfe = {
.line_num = 4,
.pd_name = "ife0",
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
/* VFE1 */
@@ -1285,7 +1311,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
.vfe = {
.line_num = 4,
.pd_name = "ife1",
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
/* VFE2 */
@@ -1303,7 +1331,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
.vfe = {
.line_num = 4,
.pd_name = "ife2",
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
/* VFE3 */
@@ -1321,7 +1351,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
.vfe = {
.line_num = 4,
.pd_name = "ife3",
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
/* VFE_LITE_0 */
@@ -1338,7 +1370,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
.vfe = {
.is_lite = true,
.line_num = 4,
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
/* VFE_LITE_1 */
@@ -1355,7 +1389,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
.vfe = {
.is_lite = true,
.line_num = 4,
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
/* VFE_LITE_2 */
@@ -1372,7 +1408,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
.vfe = {
.is_lite = true,
.line_num = 4,
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
/* VFE_LITE_3 */
@@ -1389,7 +1427,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
.vfe = {
.is_lite = true,
.line_num = 4,
- .hw_ops = &vfe_ops_170
+ .hw_ops = &vfe_ops_170,
+ .formats_rdi = &vfe_formats_rdi_845,
+ .formats_pix = &vfe_formats_pix_845
}
},
};
diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
index 2477821dfd85..4b13012940bf 100644
--- a/drivers/media/platform/qcom/camss/camss.h
+++ b/drivers/media/platform/qcom/camss/camss.h
@@ -22,6 +22,7 @@
#include "camss-csiphy.h"
#include "camss-ispif.h"
#include "camss-vfe.h"
+#include "camss-format.h"
#define to_camss(ptr_module) \
container_of(ptr_module, struct camss, ptr_module)
--
2.17.1
From: Milen Mitkov <[email protected]>
Split the RAW interface (RDI), the CSID receiver (RX)
and test pattern generator (testgen), configurations
for CSID on Titan 170
Signed-off-by: Milen Mitkov <[email protected]>
Signed-off-by: Gjorgji Rosikopulos <[email protected]>
---
.../platform/qcom/camss/camss-csid-gen2.c | 252 ++++++++++--------
1 file changed, 139 insertions(+), 113 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen2.c b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
index eb5dabe2639a..2d8398a91fc2 100644
--- a/drivers/media/platform/qcom/camss/camss-csid-gen2.c
+++ b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
@@ -176,150 +176,176 @@
#define TPG_COLOR_BOX_CFG_MODE 0
#define TPG_COLOR_BOX_PATTERN_SEL 2
-static void __csid_configure_stream(struct csid_device *csid, u8 enable, u8 vc)
+static void __csid_configure_rx(struct csid_device *csid,
+ struct csid_phy_config *phy, int vc)
{
- struct csid_testgen_config *tg = &csid->testgen;
- u32 val;
- u32 phy_sel = 0;
u8 lane_cnt = csid->phy.lane_cnt;
- /* Source pads matching RDI channels on hardware. Pad 1 -> RDI0, Pad 2 -> RDI1, etc. */
- struct v4l2_mbus_framefmt *input_format = &csid->fmt[MSM_CSID_PAD_FIRST_SRC + vc];
- const struct csid_format_info *format = csid_get_fmt_entry(csid->res->formats->formats,
- csid->res->formats->nformats,
- input_format->code);
+ int val;
if (!lane_cnt)
lane_cnt = 4;
- if (!tg->enabled)
- phy_sel = csid->phy.csiphy_id;
+ val = (lane_cnt - 1) << CSI2_RX_CFG0_NUM_ACTIVE_LANES;
+ val |= phy->lane_assign << CSI2_RX_CFG0_DL0_INPUT_SEL;
+ val |= phy->csiphy_id << CSI2_RX_CFG0_PHY_NUM_SEL;
+ writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG0);
- if (enable) {
- /*
- * DT_ID is a two bit bitfield that is concatenated with
- * the four least significant bits of the five bit VC
- * bitfield to generate an internal CID value.
- *
- * CSID_RDI_CFG0(vc)
- * DT_ID : 28:27
- * VC : 26:22
- * DT : 21:16
- *
- * CID : VC 3:0 << 2 | DT_ID 1:0
- */
- u8 dt_id = vc & 0x03;
-
- if (tg->enabled) {
- /* configure one DT, infinite frames */
- val = vc << TPG_VC_CFG0_VC_NUM;
- val |= INTELEAVING_MODE_ONE_SHOT << TPG_VC_CFG0_LINE_INTERLEAVING_MODE;
- val |= 0 << TPG_VC_CFG0_NUM_FRAMES;
- writel_relaxed(val, csid->base + CSID_TPG_VC_CFG0);
-
- val = 0x740 << TPG_VC_CFG1_H_BLANKING_COUNT;
- val |= 0x3ff << TPG_VC_CFG1_V_BLANKING_COUNT;
- writel_relaxed(val, csid->base + CSID_TPG_VC_CFG1);
-
- writel_relaxed(0x12345678, csid->base + CSID_TPG_LFSR_SEED);
-
- val = (input_format->height & 0x1fff) << TPG_DT_n_CFG_0_FRAME_HEIGHT;
- val |= (input_format->width & 0x1fff) << TPG_DT_n_CFG_0_FRAME_WIDTH;
- writel_relaxed(val, csid->base + CSID_TPG_DT_n_CFG_0(0));
-
- val = format->data_type << TPG_DT_n_CFG_1_DATA_TYPE;
- writel_relaxed(val, csid->base + CSID_TPG_DT_n_CFG_1(0));
-
- val = (tg->mode - 1) << TPG_DT_n_CFG_2_PAYLOAD_MODE;
- val |= 0xBE << TPG_DT_n_CFG_2_USER_SPECIFIED_PAYLOAD;
- val |= format->decode_format << TPG_DT_n_CFG_2_ENCODE_FORMAT;
- writel_relaxed(val, csid->base + CSID_TPG_DT_n_CFG_2(0));
-
- writel_relaxed(0, csid->base + CSID_TPG_COLOR_BARS_CFG);
-
- writel_relaxed(0, csid->base + CSID_TPG_COLOR_BOX_CFG);
- }
+ val = 1 << CSI2_RX_CFG1_PACKET_ECC_CORRECTION_EN;
+ if (vc > 3)
+ val |= 1 << CSI2_RX_CFG1_VC_MODE;
+ val |= 1 << CSI2_RX_CFG1_MISR_EN;
+ writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG1);
+}
- val = 1 << RDI_CFG0_BYTE_CNTR_EN;
- val |= 1 << RDI_CFG0_FORMAT_MEASURE_EN;
- val |= 1 << RDI_CFG0_TIMESTAMP_EN;
- /* note: for non-RDI path, this should be format->decode_format */
- val |= DECODE_FORMAT_PAYLOAD_ONLY << RDI_CFG0_DECODE_FORMAT;
- val |= format->data_type << RDI_CFG0_DATA_TYPE;
- val |= vc << RDI_CFG0_VIRTUAL_CHANNEL;
- val |= dt_id << RDI_CFG0_DT_ID;
- writel_relaxed(val, csid->base + CSID_RDI_CFG0(vc));
+static void __csid_ctrl_rdi(struct csid_device *csid, int enable, u8 rdi)
+{
+ int val;
- /* CSID_TIMESTAMP_STB_POST_IRQ */
- val = 2 << RDI_CFG1_TIMESTAMP_STB_SEL;
- writel_relaxed(val, csid->base + CSID_RDI_CFG1(vc));
+ if (enable)
+ val = HALT_CMD_RESUME_AT_FRAME_BOUNDARY << RDI_CTRL_HALT_CMD;
+ else
+ val = HALT_CMD_HALT_AT_FRAME_BOUNDARY << RDI_CTRL_HALT_CMD;
+ writel_relaxed(val, csid->base + CSID_RDI_CTRL(rdi));
+}
- val = 1;
- writel_relaxed(val, csid->base + CSID_RDI_FRM_DROP_PERIOD(vc));
+static void __csid_configure_testgen(struct csid_device *csid, u8 enable, u8 vc)
+{
+ struct csid_testgen_config *tg = &csid->testgen;
+ struct v4l2_mbus_framefmt *input_format = &csid->fmt[MSM_CSID_PAD_FIRST_SRC + vc];
+ const struct csid_format_info *format = csid_get_fmt_entry(csid->res->formats->formats,
+ csid->res->formats->nformats,
+ input_format->code);
+ u8 lane_cnt = csid->phy.lane_cnt;
+ u32 val;
- val = 0;
- writel_relaxed(val, csid->base + CSID_RDI_FRM_DROP_PATTERN(vc));
+ if (!lane_cnt)
+ lane_cnt = 4;
- val = 1;
- writel_relaxed(val, csid->base + CSID_RDI_IRQ_SUBSAMPLE_PERIOD(vc));
+ /* configure one DT, infinite frames */
+ val = vc << TPG_VC_CFG0_VC_NUM;
+ val |= INTELEAVING_MODE_ONE_SHOT << TPG_VC_CFG0_LINE_INTERLEAVING_MODE;
+ val |= 0 << TPG_VC_CFG0_NUM_FRAMES;
+ writel_relaxed(val, csid->base + CSID_TPG_VC_CFG0);
- val = 0;
- writel_relaxed(val, csid->base + CSID_RDI_IRQ_SUBSAMPLE_PATTERN(vc));
+ val = 0x740 << TPG_VC_CFG1_H_BLANKING_COUNT;
+ val |= 0x3ff << TPG_VC_CFG1_V_BLANKING_COUNT;
+ writel_relaxed(val, csid->base + CSID_TPG_VC_CFG1);
- val = 1;
- writel_relaxed(val, csid->base + CSID_RDI_RPP_PIX_DROP_PERIOD(vc));
+ writel_relaxed(0x12345678, csid->base + CSID_TPG_LFSR_SEED);
- val = 0;
- writel_relaxed(val, csid->base + CSID_RDI_RPP_PIX_DROP_PATTERN(vc));
+ val = (input_format->height & 0x1fff) << TPG_DT_n_CFG_0_FRAME_HEIGHT;
+ val |= (input_format->width & 0x1fff) << TPG_DT_n_CFG_0_FRAME_WIDTH;
+ writel_relaxed(val, csid->base + CSID_TPG_DT_n_CFG_0(0));
- val = 1;
- writel_relaxed(val, csid->base + CSID_RDI_RPP_LINE_DROP_PERIOD(vc));
+ val = format->data_type << TPG_DT_n_CFG_1_DATA_TYPE;
+ writel_relaxed(val, csid->base + CSID_TPG_DT_n_CFG_1(0));
- val = 0;
- writel_relaxed(val, csid->base + CSID_RDI_RPP_LINE_DROP_PATTERN(vc));
+ val = (tg->mode - 1) << TPG_DT_n_CFG_2_PAYLOAD_MODE;
+ val |= 0xBE << TPG_DT_n_CFG_2_USER_SPECIFIED_PAYLOAD;
+ val |= format->decode_format << TPG_DT_n_CFG_2_ENCODE_FORMAT;
+ writel_relaxed(val, csid->base + CSID_TPG_DT_n_CFG_2(0));
- val = 0;
- writel_relaxed(val, csid->base + CSID_RDI_CTRL(vc));
+ writel_relaxed(0, csid->base + CSID_TPG_COLOR_BARS_CFG);
- val = readl_relaxed(csid->base + CSID_RDI_CFG0(vc));
- val |= 1 << RDI_CFG0_ENABLE;
- writel_relaxed(val, csid->base + CSID_RDI_CFG0(vc));
- }
+ writel_relaxed(0, csid->base + CSID_TPG_COLOR_BOX_CFG);
- if (tg->enabled) {
- val = enable << TPG_CTRL_TEST_EN;
- val |= 1 << TPG_CTRL_FS_PKT_EN;
- val |= 1 << TPG_CTRL_FE_PKT_EN;
- val |= (lane_cnt - 1) << TPG_CTRL_NUM_ACTIVE_LANES;
- val |= 0x64 << TPG_CTRL_CYCLES_BETWEEN_PKTS;
- val |= 0xA << TPG_CTRL_NUM_TRAIL_BYTES;
- writel_relaxed(val, csid->base + CSID_TPG_CTRL);
- }
+ val = enable << TPG_CTRL_TEST_EN;
+ val |= 1 << TPG_CTRL_FS_PKT_EN;
+ val |= 1 << TPG_CTRL_FE_PKT_EN;
+ val |= (lane_cnt - 1) << TPG_CTRL_NUM_ACTIVE_LANES;
+ val |= 0x64 << TPG_CTRL_CYCLES_BETWEEN_PKTS;
+ val |= 0xA << TPG_CTRL_NUM_TRAIL_BYTES;
+ writel_relaxed(val, csid->base + CSID_TPG_CTRL);
+}
- val = (lane_cnt - 1) << CSI2_RX_CFG0_NUM_ACTIVE_LANES;
- val |= csid->phy.lane_assign << CSI2_RX_CFG0_DL0_INPUT_SEL;
- val |= phy_sel << CSI2_RX_CFG0_PHY_NUM_SEL;
- writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG0);
+static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8 vc)
+{
+ struct csid_testgen_config *tg = &csid->testgen;
+ u32 val;
+ u32 phy_sel = 0;
+ /* Source pads matching RDI channels on hardware. Pad 1 -> RDI0, Pad 2 -> RDI1, etc. */
+ struct v4l2_mbus_framefmt *input_format = &csid->fmt[MSM_CSID_PAD_FIRST_SRC + vc];
+ const struct csid_format_info *format = csid_get_fmt_entry(csid->res->formats->formats,
+ csid->res->formats->nformats,
+ input_format->code);
- val = 1 << CSI2_RX_CFG1_PACKET_ECC_CORRECTION_EN;
- if (vc > 3)
- val |= 1 << CSI2_RX_CFG1_VC_MODE;
- val |= 1 << CSI2_RX_CFG1_MISR_EN;
- writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG1);
+ if (!tg->enabled)
+ phy_sel = csid->phy.csiphy_id;
- if (enable)
- val = HALT_CMD_RESUME_AT_FRAME_BOUNDARY << RDI_CTRL_HALT_CMD;
- else
- val = HALT_CMD_HALT_AT_FRAME_BOUNDARY << RDI_CTRL_HALT_CMD;
+ /*
+ * DT_ID is a two bit bitfield that is concatenated with
+ * the four least significant bits of the five bit VC
+ * bitfield to generate an internal CID value.
+ *
+ * CSID_RDI_CFG0(vc)
+ * DT_ID : 28:27
+ * VC : 26:22
+ * DT : 21:16
+ *
+ * CID : VC 3:0 << 2 | DT_ID 1:0
+ */
+ u8 dt_id = vc & 0x03;
+
+ val = 1 << RDI_CFG0_BYTE_CNTR_EN;
+ val |= 1 << RDI_CFG0_FORMAT_MEASURE_EN;
+ val |= 1 << RDI_CFG0_TIMESTAMP_EN;
+ /* note: for non-RDI path, this should be format->decode_format */
+ val |= DECODE_FORMAT_PAYLOAD_ONLY << RDI_CFG0_DECODE_FORMAT;
+ val |= format->data_type << RDI_CFG0_DATA_TYPE;
+ val |= vc << RDI_CFG0_VIRTUAL_CHANNEL;
+ val |= dt_id << RDI_CFG0_DT_ID;
+ writel_relaxed(val, csid->base + CSID_RDI_CFG0(vc));
+
+ /* CSID_TIMESTAMP_STB_POST_IRQ */
+ val = 2 << RDI_CFG1_TIMESTAMP_STB_SEL;
+ writel_relaxed(val, csid->base + CSID_RDI_CFG1(vc));
+
+ val = 1;
+ writel_relaxed(val, csid->base + CSID_RDI_FRM_DROP_PERIOD(vc));
+
+ val = 0;
+ writel_relaxed(val, csid->base + CSID_RDI_FRM_DROP_PATTERN(vc));
+
+ val = 1;
+ writel_relaxed(val, csid->base + CSID_RDI_IRQ_SUBSAMPLE_PERIOD(vc));
+
+ val = 0;
+ writel_relaxed(val, csid->base + CSID_RDI_IRQ_SUBSAMPLE_PATTERN(vc));
+
+ val = 1;
+ writel_relaxed(val, csid->base + CSID_RDI_RPP_PIX_DROP_PERIOD(vc));
+
+ val = 0;
+ writel_relaxed(val, csid->base + CSID_RDI_RPP_PIX_DROP_PATTERN(vc));
+
+ val = 1;
+ writel_relaxed(val, csid->base + CSID_RDI_RPP_LINE_DROP_PERIOD(vc));
+
+ val = 0;
+ writel_relaxed(val, csid->base + CSID_RDI_RPP_LINE_DROP_PATTERN(vc));
+
+ val = 0;
writel_relaxed(val, csid->base + CSID_RDI_CTRL(vc));
+
+ val = readl_relaxed(csid->base + CSID_RDI_CFG0(vc));
+ val |= enable << RDI_CFG0_ENABLE;
+ writel_relaxed(val, csid->base + CSID_RDI_CFG0(vc));
}
static void csid_configure_stream(struct csid_device *csid, u8 enable)
{
+ struct csid_testgen_config *tg = &csid->testgen;
u8 i;
/* Loop through all enabled VCs and configure stream for each */
for (i = 0; i < MSM_CSID_MAX_SRC_STREAMS; i++)
- if (csid->phy.en_vc & BIT(i))
- __csid_configure_stream(csid, enable, i);
+ if (csid->phy.en_vc & BIT(i)) {
+ if (tg->enabled)
+ __csid_configure_testgen(csid, enable, i);
+
+ __csid_configure_rdi_stream(csid, enable, i);
+ __csid_configure_rx(csid, &csid->phy, i);
+ __csid_ctrl_rdi(csid, enable, i);
+ }
}
static int csid_configure_testgen_pattern(struct csid_device *csid, s32 val)
--
2.17.1
From: Atanas Filipov <[email protected]>
Split link and register operations.
Add dedicated link callback according to SoC identifier.
Signed-off-by: Atanas Filipov <[email protected]>
Signed-off-by: Gjorgji Rosikopulos <[email protected]>
---
drivers/media/platform/qcom/camss/camss.c | 141 ++++++++++++----------
drivers/media/platform/qcom/camss/camss.h | 1 +
2 files changed, 81 insertions(+), 61 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index d57bbea32107..37060eaa0ba5 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -1807,72 +1807,30 @@ static int camss_init_subdevices(struct camss *camss)
}
/*
- * camss_register_entities - Register subdev nodes and create links
+ * camss_link_entities - Register subdev nodes and create links
* @camss: CAMSS device
*
* Return 0 on success or a negative error code on failure
*/
-static int camss_register_entities(struct camss *camss)
+static int camss_link_entities(struct camss *camss)
{
int i, j, k;
int ret;
- for (i = 0; i < camss->res->csiphy_num; i++) {
- ret = msm_csiphy_register_entity(&camss->csiphy[i],
- &camss->v4l2_dev);
- if (ret < 0) {
- dev_err(camss->dev,
- "Failed to register csiphy%d entity: %d\n",
- i, ret);
- goto err_reg_csiphy;
- }
- }
-
- for (i = 0; i < camss->res->csid_num; i++) {
- ret = msm_csid_register_entity(&camss->csid[i],
- &camss->v4l2_dev);
- if (ret < 0) {
- dev_err(camss->dev,
- "Failed to register csid%d entity: %d\n",
- i, ret);
- goto err_reg_csid;
- }
- }
-
- ret = msm_ispif_register_entities(camss->ispif,
- &camss->v4l2_dev);
- if (ret < 0) {
- dev_err(camss->dev, "Failed to register ispif entities: %d\n",
- ret);
- goto err_reg_ispif;
- }
-
- for (i = 0; i < camss->res->vfe_num; i++) {
- ret = msm_vfe_register_entities(&camss->vfe[i],
- &camss->v4l2_dev);
- if (ret < 0) {
- dev_err(camss->dev,
- "Failed to register vfe%d entities: %d\n",
- i, ret);
- goto err_reg_vfe;
- }
- }
-
for (i = 0; i < camss->res->csiphy_num; i++) {
for (j = 0; j < camss->res->csid_num; j++) {
- ret = media_create_pad_link(
- &camss->csiphy[i].subdev.entity,
- MSM_CSIPHY_PAD_SRC,
- &camss->csid[j].subdev.entity,
- MSM_CSID_PAD_SINK,
- 0);
+ ret = media_create_pad_link(&camss->csiphy[i].subdev.entity,
+ MSM_CSIPHY_PAD_SRC,
+ &camss->csid[j].subdev.entity,
+ MSM_CSID_PAD_SINK,
+ 0);
if (ret < 0) {
dev_err(camss->dev,
"Failed to link %s->%s entities: %d\n",
camss->csiphy[i].subdev.entity.name,
camss->csid[j].subdev.entity.name,
ret);
- goto err_link;
+ return ret;
}
}
}
@@ -1880,19 +1838,18 @@ static int camss_register_entities(struct camss *camss)
if (camss->ispif) {
for (i = 0; i < camss->res->csid_num; i++) {
for (j = 0; j < camss->ispif->line_num; j++) {
- ret = media_create_pad_link(
- &camss->csid[i].subdev.entity,
- MSM_CSID_PAD_SRC,
- &camss->ispif->line[j].subdev.entity,
- MSM_ISPIF_PAD_SINK,
- 0);
+ ret = media_create_pad_link(&camss->csid[i].subdev.entity,
+ MSM_CSID_PAD_SRC,
+ &camss->ispif->line[j].subdev.entity,
+ MSM_ISPIF_PAD_SINK,
+ 0);
if (ret < 0) {
dev_err(camss->dev,
"Failed to link %s->%s entities: %d\n",
camss->csid[i].subdev.entity.name,
camss->ispif->line[j].subdev.entity.name,
ret);
- goto err_link;
+ return ret;
}
}
}
@@ -1914,7 +1871,7 @@ static int camss_register_entities(struct camss *camss)
ispif->entity.name,
vfe->entity.name,
ret);
- goto err_link;
+ return ret;
}
}
} else {
@@ -1935,15 +1892,67 @@ static int camss_register_entities(struct camss *camss)
csid->entity.name,
vfe->entity.name,
ret);
- goto err_link;
+ return ret;
}
}
}
+ return 0;
+}
+
+/*
+ * camss_register_entities - Register subdev nodes and create links
+ * @camss: CAMSS device
+ *
+ * Return 0 on success or a negative error code on failure
+ */
+static int camss_register_entities(struct camss *camss)
+{
+ int i;
+ int ret;
+
+ for (i = 0; i < camss->res->csiphy_num; i++) {
+ ret = msm_csiphy_register_entity(&camss->csiphy[i],
+ &camss->v4l2_dev);
+ if (ret < 0) {
+ dev_err(camss->dev,
+ "Failed to register csiphy%d entity: %d\n",
+ i, ret);
+ goto err_reg_csiphy;
+ }
+ }
+
+ for (i = 0; i < camss->res->csid_num; i++) {
+ ret = msm_csid_register_entity(&camss->csid[i],
+ &camss->v4l2_dev);
+ if (ret < 0) {
+ dev_err(camss->dev,
+ "Failed to register csid%d entity: %d\n",
+ i, ret);
+ goto err_reg_csid;
+ }
+ }
+
+ ret = msm_ispif_register_entities(camss->ispif,
+ &camss->v4l2_dev);
+ if (ret < 0) {
+ dev_err(camss->dev, "Failed to register ispif entities: %d\n", ret);
+ goto err_reg_ispif;
+ }
+
+ for (i = 0; i < camss->res->vfe_num; i++) {
+ ret = msm_vfe_register_entities(&camss->vfe[i],
+ &camss->v4l2_dev);
+ if (ret < 0) {
+ dev_err(camss->dev,
+ "Failed to register vfe%d entities: %d\n",
+ i, ret);
+ goto err_reg_vfe;
+ }
+ }
+
return 0;
-err_link:
- i = camss->res->vfe_num;
err_reg_vfe:
for (i--; i >= 0; i--)
msm_vfe_unregister_entities(&camss->vfe[i]);
@@ -2263,6 +2272,10 @@ static int camss_probe(struct platform_device *pdev)
if (ret < 0)
goto err_v4l2_device_unregister;
+ ret = camss->res->link_entities(camss);
+ if (ret < 0)
+ goto err_register_subdevs;
+
if (num_subdevs) {
camss->notifier.ops = &camss_subdev_notifier_ops;
@@ -2342,6 +2355,7 @@ static const struct camss_resources msm8916_resources = {
.csiphy_num = ARRAY_SIZE(csiphy_res_8x16),
.csid_num = ARRAY_SIZE(csid_res_8x16),
.vfe_num = ARRAY_SIZE(vfe_res_8x16),
+ .link_entities = camss_link_entities
};
static const struct camss_resources msm8996_resources = {
@@ -2353,6 +2367,7 @@ static const struct camss_resources msm8996_resources = {
.csiphy_num = ARRAY_SIZE(csiphy_res_8x96),
.csid_num = ARRAY_SIZE(csid_res_8x96),
.vfe_num = ARRAY_SIZE(vfe_res_8x96),
+ .link_entities = camss_link_entities
};
static const struct camss_resources sdm660_resources = {
@@ -2364,6 +2379,7 @@ static const struct camss_resources sdm660_resources = {
.csiphy_num = ARRAY_SIZE(csiphy_res_660),
.csid_num = ARRAY_SIZE(csid_res_660),
.vfe_num = ARRAY_SIZE(vfe_res_660),
+ .link_entities = camss_link_entities
};
static const struct camss_resources sdm845_resources = {
@@ -2374,6 +2390,7 @@ static const struct camss_resources sdm845_resources = {
.csiphy_num = ARRAY_SIZE(csiphy_res_845),
.csid_num = ARRAY_SIZE(csid_res_845),
.vfe_num = ARRAY_SIZE(vfe_res_845),
+ .link_entities = camss_link_entities
};
static const struct camss_resources sm8250_resources = {
@@ -2387,6 +2404,7 @@ static const struct camss_resources sm8250_resources = {
.csiphy_num = ARRAY_SIZE(csiphy_res_8250),
.csid_num = ARRAY_SIZE(csid_res_8250),
.vfe_num = ARRAY_SIZE(vfe_res_8250),
+ .link_entities = camss_link_entities
};
static const struct camss_resources sc8280xp_resources = {
@@ -2401,6 +2419,7 @@ static const struct camss_resources sc8280xp_resources = {
.csiphy_num = ARRAY_SIZE(csiphy_res_sc8280xp),
.csid_num = ARRAY_SIZE(csid_res_sc8280xp),
.vfe_num = ARRAY_SIZE(vfe_res_sc8280xp),
+ .link_entities = camss_link_entities
};
static const struct of_device_id camss_dt_match[] = {
diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
index 4b13012940bf..a5be9e872992 100644
--- a/drivers/media/platform/qcom/camss/camss.h
+++ b/drivers/media/platform/qcom/camss/camss.h
@@ -106,6 +106,7 @@ struct camss_resources {
const unsigned int csiphy_num;
const unsigned int csid_num;
const unsigned int vfe_num;
+ int (*link_entities)(struct camss *camss);
};
struct camss {
--
2.17.1
From: Milen Mitkov <[email protected]>
Decouple the direct calls to VFE's vfe_get/put in the CSID subdev
in order to prepare for the introduction of IFE subdev.
Also decouple CSID base address from VFE since on the Titan platform
CSID register base address resides within VFE's base address.
Signed-off-by: Milen Mitkov <[email protected]>
Signed-off-by: Gjorgji Rosikopulos <[email protected]>
---
.../media/platform/qcom/camss/camss-csid.c | 16 +++--
.../media/platform/qcom/camss/camss-csid.h | 1 +
drivers/media/platform/qcom/camss/camss.c | 69 +++++++++++++++++++
drivers/media/platform/qcom/camss/camss.h | 8 +++
4 files changed, 89 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index 5b23f5b8746d..858db5d4ca75 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -602,7 +602,6 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
struct csid_device *csid = v4l2_get_subdevdata(sd);
struct camss *camss = csid->camss;
struct device *dev = camss->dev;
- struct vfe_device *vfe = &camss->vfe[csid->id];
int ret = 0;
if (on) {
@@ -611,7 +610,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
* switching on the CSID. Do so unconditionally, as there is no
* drawback in following the same powering order on older SoCs.
*/
- ret = vfe_get(vfe);
+ ret = csid->res->parent_dev_ops->get(camss, csid->id);
if (ret < 0)
return ret;
@@ -663,7 +662,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
regulator_bulk_disable(csid->num_supplies,
csid->supplies);
pm_runtime_put_sync(dev);
- vfe_put(vfe);
+ csid->res->parent_dev_ops->put(camss, csid->id);
}
return ret;
@@ -1021,6 +1020,11 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
csid->id = id;
csid->res = &res->csid;
+ if (dev_WARN_ONCE(dev, !csid->res->parent_dev_ops,
+ "Error: CSID depends on VFE/IFE device ops!\n")) {
+ return -EINVAL;
+ }
+
csid->res->hw_ops->subdev_init(csid);
/* Memory */
@@ -1031,9 +1035,11 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
* VFE to be initialized before CSID
*/
if (id >= 2) /* VFE/CSID lite */
- csid->base = camss->vfe[id].base + VFE_480_LITE_CSID_OFFSET;
+ csid->base = csid->res->parent_dev_ops->get_base_address(camss, id)
+ + VFE_480_LITE_CSID_OFFSET;
else
- csid->base = camss->vfe[id].base + VFE_480_CSID_OFFSET;
+ csid->base = csid->res->parent_dev_ops->get_base_address(camss, id)
+ + VFE_480_CSID_OFFSET;
} else {
csid->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]);
if (IS_ERR(csid->base))
diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media/platform/qcom/camss/camss-csid.h
index 0e385d17c250..8cdae98e4dca 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.h
+++ b/drivers/media/platform/qcom/camss/camss-csid.h
@@ -157,6 +157,7 @@ struct csid_hw_ops {
struct csid_subdev_resources {
bool is_lite;
const struct csid_hw_ops *hw_ops;
+ const struct parent_dev_ops *parent_dev_ops;
const struct csid_formats *formats;
};
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index 37060eaa0ba5..4d625ef59cf7 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -32,6 +32,8 @@
#define CAMSS_CLOCK_MARGIN_NUMERATOR 105
#define CAMSS_CLOCK_MARGIN_DENOMINATOR 100
+static const struct parent_dev_ops vfe_parent_dev_ops;
+
static const struct camss_subdev_resources csiphy_res_8x16[] = {
/* CSIPHY0 */
{
@@ -87,6 +89,7 @@ static const struct camss_subdev_resources csid_res_8x16[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_4_1,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_4_1
}
},
@@ -109,6 +112,7 @@ static const struct camss_subdev_resources csid_res_8x16[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_4_1,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_4_1
}
},
@@ -226,6 +230,7 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_4_7,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_4_7
}
},
@@ -248,6 +253,7 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_4_7,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_4_7
}
},
@@ -270,6 +276,7 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_4_7,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_4_7
}
},
@@ -292,6 +299,7 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_4_7,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_4_7
}
}
@@ -445,6 +453,7 @@ static const struct camss_subdev_resources csid_res_660[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_4_7,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_4_7
}
},
@@ -470,6 +479,7 @@ static const struct camss_subdev_resources csid_res_660[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_4_7,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_4_7
}
},
@@ -495,6 +505,7 @@ static const struct camss_subdev_resources csid_res_660[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_4_7,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_4_7
}
},
@@ -520,6 +531,7 @@ static const struct camss_subdev_resources csid_res_660[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_4_7,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_4_7
}
}
@@ -714,6 +726,7 @@ static const struct camss_subdev_resources csid_res_845[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -739,6 +752,7 @@ static const struct camss_subdev_resources csid_res_845[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -765,6 +779,7 @@ static const struct camss_subdev_resources csid_res_845[] = {
.csid = {
.is_lite = true,
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
}
@@ -957,6 +972,7 @@ static const struct camss_subdev_resources csid_res_8250[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -974,6 +990,7 @@ static const struct camss_subdev_resources csid_res_8250[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -991,6 +1008,7 @@ static const struct camss_subdev_resources csid_res_8250[] = {
.csid = {
.is_lite = true,
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -1008,6 +1026,7 @@ static const struct camss_subdev_resources csid_res_8250[] = {
.csid = {
.is_lite = true,
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
}
@@ -1212,6 +1231,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.interrupt = { "csid0" },
.csid = {
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -1227,6 +1247,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.interrupt = { "csid1" },
.csid = {
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -1242,6 +1263,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.interrupt = { "csid2" },
.csid = {
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -1257,6 +1279,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.interrupt = { "csid3" },
.csid = {
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -1272,6 +1295,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.csid = {
.is_lite = true,
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -1287,6 +1311,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.csid = {
.is_lite = true,
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -1302,6 +1327,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.csid = {
.is_lite = true,
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
},
@@ -1317,6 +1343,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.csid = {
.is_lite = true,
.hw_ops = &csid_ops_gen2,
+ .parent_dev_ops = &vfe_parent_dev_ops,
.formats = &csid_formats_gen2
}
}
@@ -1661,6 +1688,48 @@ void camss_pm_domain_off(struct camss *camss, int id)
}
}
+static int vfe_parent_dev_ops_get(struct camss *camss, int id)
+{
+ int ret = -EINVAL;
+
+ if (id < camss->res->vfe_num) {
+ struct vfe_device *vfe = &camss->vfe[id];
+
+ ret = vfe_get(vfe);
+ }
+
+ return ret;
+}
+
+static int vfe_parent_dev_ops_put(struct camss *camss, int id)
+{
+ if (id < camss->res->vfe_num) {
+ struct vfe_device *vfe = &camss->vfe[id];
+
+ vfe_put(vfe);
+ }
+
+ return 0;
+}
+
+static void __iomem
+*vfe_parent_dev_ops_get_base_address(struct camss *camss, int id)
+{
+ if (id < camss->res->vfe_num) {
+ struct vfe_device *vfe = &camss->vfe[id];
+
+ return vfe->base;
+ }
+
+ return NULL;
+}
+
+static const struct parent_dev_ops vfe_parent_dev_ops = {
+ .get = vfe_parent_dev_ops_get,
+ .put = vfe_parent_dev_ops_put,
+ .get_base_address = vfe_parent_dev_ops_get_base_address
+};
+
/*
* camss_of_parse_endpoint_node - Parse port endpoint node
* @dev: Device
diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
index a5be9e872992..b3c967bcf8a9 100644
--- a/drivers/media/platform/qcom/camss/camss.h
+++ b/drivers/media/platform/qcom/camss/camss.h
@@ -143,6 +143,12 @@ struct camss_clock {
u32 nfreqs;
};
+struct parent_dev_ops {
+ int (*get)(struct camss *camss, int id);
+ int (*put)(struct camss *camss, int id);
+ void __iomem *(*get_base_address)(struct camss *camss, int id);
+};
+
void camss_add_clock_margin(u64 *rate);
int camss_enable_clocks(int nclocks, struct camss_clock *clock,
struct device *dev);
@@ -153,6 +159,8 @@ s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp,
int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock);
int camss_pm_domain_on(struct camss *camss, int id);
void camss_pm_domain_off(struct camss *camss, int id);
+int camss_vfe_get(struct camss *camss, int id);
+void camss_vfe_put(struct camss *camss, int id);
void camss_delete(struct camss *camss);
#endif /* QC_MSM_CAMSS_H */
--
2.17.1
From: Radoslav Tsvetkov <[email protected]>
Currently resources structure grows with additional parameters required for
each sub-deivce. However each sub-device has some specific resources or
configurations which need to be passed during the initialization.
This change adds per sub-device type structure to simplify the things
and removes the magical void pointer to hw_ops.
Signed-off-by: Radoslav Tsvetkov <[email protected]>
Signed-off-by: Gjorgji Rosikopulos <[email protected]>
---
.../media/platform/qcom/camss/camss-csid.c | 22 +-
.../media/platform/qcom/camss/camss-csid.h | 7 +-
.../media/platform/qcom/camss/camss-csiphy.c | 14 +-
.../media/platform/qcom/camss/camss-csiphy.h | 6 +-
.../media/platform/qcom/camss/camss-vfe-17x.c | 10 +-
.../media/platform/qcom/camss/camss-vfe-4-1.c | 4 +-
.../media/platform/qcom/camss/camss-vfe-4-7.c | 6 +-
.../media/platform/qcom/camss/camss-vfe-4-8.c | 6 +-
.../platform/qcom/camss/camss-vfe-gen1.c | 8 +-
drivers/media/platform/qcom/camss/camss-vfe.c | 54 ++-
drivers/media/platform/qcom/camss/camss-vfe.h | 11 +-
drivers/media/platform/qcom/camss/camss.c | 432 +++++++++++++-----
drivers/media/platform/qcom/camss/camss.h | 18 +-
13 files changed, 402 insertions(+), 196 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index eb27d69e89a1..d1a22e07fdb6 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -202,7 +202,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
enable_irq(csid->irq);
- ret = csid->ops->reset(csid);
+ ret = csid->res->hw_ops->reset(csid);
if (ret < 0) {
disable_irq(csid->irq);
camss_disable_clocks(csid->nclocks, csid->clock);
@@ -212,7 +212,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
return ret;
}
- csid->ops->hw_version(csid);
+ csid->res->hw_ops->hw_version(csid);
} else {
disable_irq(csid->irq);
camss_disable_clocks(csid->nclocks, csid->clock);
@@ -253,7 +253,7 @@ static int csid_set_stream(struct v4l2_subdev *sd, int enable)
}
if (csid->phy.need_vc_update) {
- csid->ops->configure_stream(csid, enable);
+ csid->res->hw_ops->configure_stream(csid, enable);
csid->phy.need_vc_update = false;
}
@@ -325,7 +325,7 @@ static void csid_try_format(struct csid_device *csid,
*fmt = *__csid_get_format(csid, sd_state,
MSM_CSID_PAD_SINK, which);
- fmt->code = csid->ops->src_pad_code(csid, fmt->code, 0, code);
+ fmt->code = csid->res->hw_ops->src_pad_code(csid, fmt->code, 0, code);
} else {
/* Test generator is enabled, set format on source */
/* pad to allow test generator usage */
@@ -375,8 +375,8 @@ static int csid_enum_mbus_code(struct v4l2_subdev *sd,
MSM_CSID_PAD_SINK,
code->which);
- code->code = csid->ops->src_pad_code(csid, sink_fmt->code,
- code->index, 0);
+ code->code = csid->res->hw_ops->src_pad_code(csid, sink_fmt->code,
+ code->index, 0);
if (!code->code)
return -EINVAL;
} else {
@@ -529,7 +529,7 @@ static int csid_set_test_pattern(struct csid_device *csid, s32 value)
tg->enabled = !!value;
- return csid->ops->configure_testgen_pattern(csid, value);
+ return csid->res->hw_ops->configure_testgen_pattern(csid, value);
}
/*
@@ -575,9 +575,9 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
csid->camss = camss;
csid->id = id;
- csid->ops = res->ops;
+ csid->res = &res->csid;
- csid->ops->subdev_init(csid);
+ csid->res->hw_ops->subdev_init(csid);
/* Memory */
@@ -605,7 +605,7 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
csid->irq = ret;
snprintf(csid->irq_name, sizeof(csid->irq_name), "%s_%s%d",
dev_name(dev), MSM_CSID_NAME, csid->id);
- ret = devm_request_irq(dev, csid->irq, csid->ops->isr,
+ ret = devm_request_irq(dev, csid->irq, csid->res->hw_ops->isr,
IRQF_TRIGGER_RISING | IRQF_NO_AUTOEN,
csid->irq_name, csid);
if (ret < 0) {
@@ -899,5 +899,5 @@ void msm_csid_unregister_entity(struct csid_device *csid)
inline bool csid_is_lite(struct csid_device *csid)
{
- return csid->camss->res->csid_res[csid->id].is_lite;
+ return csid->camss->res->csid_res[csid->id].csid.is_lite;
}
diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media/platform/qcom/camss/camss-csid.h
index fddccb69da13..8d2971aa9ef8 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.h
+++ b/drivers/media/platform/qcom/camss/camss-csid.h
@@ -149,6 +149,11 @@ struct csid_hw_ops {
void (*subdev_init)(struct csid_device *csid);
};
+struct csid_subdev_resources {
+ bool is_lite;
+ const struct csid_hw_ops *hw_ops;
+};
+
struct csid_device {
struct camss *camss;
u8 id;
@@ -169,7 +174,7 @@ struct csid_device {
struct v4l2_ctrl *testgen_mode;
const struct csid_format *formats;
unsigned int nformats;
- const struct csid_hw_ops *ops;
+ const struct csid_subdev_resources *res;
};
struct camss_subdev_resources;
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
index 45b3a8e5dea4..f26ddf1af9d4 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
@@ -216,9 +216,9 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int on)
enable_irq(csiphy->irq);
- csiphy->ops->reset(csiphy);
+ csiphy->res->hw_ops->reset(csiphy);
- csiphy->ops->hw_version_read(csiphy, dev);
+ csiphy->res->hw_ops->hw_version_read(csiphy, dev);
} else {
disable_irq(csiphy->irq);
@@ -243,7 +243,7 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
{
struct csiphy_config *cfg = &csiphy->cfg;
s64 link_freq;
- u8 lane_mask = csiphy->ops->get_lane_mask(&cfg->csi2->lane_cfg);
+ u8 lane_mask = csiphy->res->hw_ops->get_lane_mask(&cfg->csi2->lane_cfg);
u8 bpp = csiphy_get_bpp(csiphy->formats, csiphy->nformats,
csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
@@ -272,7 +272,7 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
wmb();
}
- csiphy->ops->lanes_enable(csiphy, cfg, link_freq, lane_mask);
+ csiphy->res->hw_ops->lanes_enable(csiphy, cfg, link_freq, lane_mask);
return 0;
}
@@ -285,7 +285,7 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
*/
static void csiphy_stream_off(struct csiphy_device *csiphy)
{
- csiphy->ops->lanes_disable(csiphy, &csiphy->cfg);
+ csiphy->res->hw_ops->lanes_disable(csiphy, &csiphy->cfg);
}
@@ -564,7 +564,7 @@ int msm_csiphy_subdev_init(struct camss *camss,
csiphy->camss = camss;
csiphy->id = id;
csiphy->cfg.combo_mode = 0;
- csiphy->ops = res->ops;
+ csiphy->res = &res->csiphy;
switch (camss->res->version) {
case CAMSS_8x16:
@@ -610,7 +610,7 @@ int msm_csiphy_subdev_init(struct camss *camss,
snprintf(csiphy->irq_name, sizeof(csiphy->irq_name), "%s_%s%d",
dev_name(dev), MSM_CSIPHY_NAME, csiphy->id);
- ret = devm_request_irq(dev, csiphy->irq, csiphy->ops->isr,
+ ret = devm_request_irq(dev, csiphy->irq, csiphy->res->hw_ops->isr,
IRQF_TRIGGER_RISING | IRQF_NO_AUTOEN,
csiphy->irq_name, csiphy);
if (ret < 0) {
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/media/platform/qcom/camss/camss-csiphy.h
index c9b7fe82b1f0..7bd68129ca49 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.h
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.h
@@ -63,6 +63,10 @@ struct csiphy_hw_ops {
irqreturn_t (*isr)(int irq, void *dev);
};
+struct csiphy_subdev_resources {
+ const struct csiphy_hw_ops *hw_ops;
+};
+
struct csiphy_device {
struct camss *camss;
u8 id;
@@ -78,7 +82,7 @@ struct csiphy_device {
u32 timer_clk_rate;
struct csiphy_config cfg;
struct v4l2_mbus_framefmt fmt[MSM_CSIPHY_PADS_NUM];
- const struct csiphy_hw_ops *ops;
+ const struct csiphy_subdev_resources *res;
const struct csiphy_format *formats;
unsigned int nformats;
};
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
index 795ac3815339..380c99321030 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
@@ -353,7 +353,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
writel_relaxed(status0, vfe->base + VFE_IRQ_CLEAR_0);
writel_relaxed(status1, vfe->base + VFE_IRQ_CLEAR_1);
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) {
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
vfe_bus_status[i] = readl_relaxed(vfe->base + VFE_BUS_IRQ_STATUS(i));
writel_relaxed(vfe_bus_status[i], vfe->base + VFE_BUS_IRQ_CLEAR(i));
}
@@ -367,11 +367,11 @@ static irqreturn_t vfe_isr(int irq, void *dev)
if (status0 & STATUS_0_RESET_ACK)
vfe->isr_ops.reset_ack(vfe);
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++)
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++)
if (status0 & STATUS_0_RDI_REG_UPDATE(i))
vfe->isr_ops.reg_update(vfe, i);
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++)
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++)
if (status0 & STATUS_1_RDI_SOF(i))
vfe->isr_ops.sof(vfe, i);
@@ -442,7 +442,7 @@ static int vfe_enable_output(struct vfe_line *line)
{
struct vfe_device *vfe = to_vfe(line);
struct vfe_output *output = &line->output;
- const struct vfe_hw_ops *ops = vfe->ops;
+ const struct vfe_hw_ops *ops = vfe->res->hw_ops;
struct media_entity *sensor;
unsigned long flags;
unsigned int frame_skip = 0;
@@ -560,7 +560,7 @@ static void vfe_isr_reg_update(struct vfe_device *vfe, enum vfe_line_id line_id)
unsigned long flags;
spin_lock_irqsave(&vfe->output_lock, flags);
- vfe->ops->reg_update_clear(vfe, line_id);
+ vfe->res->hw_ops->reg_update_clear(vfe, line_id);
output = &vfe->line[line_id].output;
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c
index ef6b34c915df..1bd3a6ef1d04 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c
@@ -892,7 +892,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
u32 value0, value1;
int i, j;
- vfe->ops->isr_read(vfe, &value0, &value1);
+ vfe->res->hw_ops->isr_read(vfe, &value0, &value1);
dev_dbg(vfe->camss->dev, "VFE: status0 = 0x%08x, status1 = 0x%08x\n",
value0, value1);
@@ -901,7 +901,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
vfe->isr_ops.reset_ack(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_VIOLATION)
- vfe->ops->violation_read(vfe);
+ vfe->res->hw_ops->violation_read(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_BUS_BDG_HALT_ACK)
vfe->isr_ops.halt_ack(vfe);
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c
index 7655d22a9fda..ce0719106bd3 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c
@@ -1050,7 +1050,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
u32 value0, value1;
int i, j;
- vfe->ops->isr_read(vfe, &value0, &value1);
+ vfe->res->hw_ops->isr_read(vfe, &value0, &value1);
dev_dbg(vfe->camss->dev, "VFE: status0 = 0x%08x, status1 = 0x%08x\n",
value0, value1);
@@ -1059,12 +1059,12 @@ static irqreturn_t vfe_isr(int irq, void *dev)
vfe->isr_ops.reset_ack(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_VIOLATION)
- vfe->ops->violation_read(vfe);
+ vfe->res->hw_ops->violation_read(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_BUS_BDG_HALT_ACK)
vfe->isr_ops.halt_ack(vfe);
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++)
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++)
if (value0 & VFE_0_IRQ_STATUS_0_line_n_REG_UPDATE(i))
vfe->isr_ops.reg_update(vfe, i);
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c
index f52fa30f3853..6b59c8107a3c 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c
@@ -980,7 +980,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
u32 value0, value1;
int i, j;
- vfe->ops->isr_read(vfe, &value0, &value1);
+ vfe->res->hw_ops->isr_read(vfe, &value0, &value1);
dev_dbg(vfe->camss->dev, "VFE: status0 = 0x%08x, status1 = 0x%08x\n",
value0, value1);
@@ -989,12 +989,12 @@ static irqreturn_t vfe_isr(int irq, void *dev)
vfe->isr_ops.reset_ack(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_VIOLATION)
- vfe->ops->violation_read(vfe);
+ vfe->res->hw_ops->violation_read(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_BUS_BDG_HALT_ACK)
vfe->isr_ops.halt_ack(vfe);
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++)
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++)
if (value0 & VFE_0_IRQ_STATUS_0_line_n_REG_UPDATE(i))
vfe->isr_ops.reg_update(vfe, i);
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-gen1.c b/drivers/media/platform/qcom/camss/camss-vfe-gen1.c
index 239d3d4ac666..eb33c03df27e 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-gen1.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-gen1.c
@@ -37,7 +37,7 @@ static int vfe_disable_output(struct vfe_line *line)
{
struct vfe_device *vfe = to_vfe(line);
struct vfe_output *output = &line->output;
- const struct vfe_hw_ops *ops = vfe->ops;
+ const struct vfe_hw_ops *ops = vfe->res->hw_ops;
unsigned long flags;
unsigned long time;
unsigned int i;
@@ -162,14 +162,14 @@ static void vfe_output_frame_drop(struct vfe_device *vfe,
vfe->ops_gen1->wm_set_framedrop_pattern(vfe, output->wm_idx[i], drop_pattern);
}
- vfe->ops->reg_update(vfe, container_of(output, struct vfe_line, output)->id);
+ vfe->res->hw_ops->reg_update(vfe, container_of(output, struct vfe_line, output)->id);
}
static int vfe_enable_output(struct vfe_line *line)
{
struct vfe_device *vfe = to_vfe(line);
struct vfe_output *output = &line->output;
- const struct vfe_hw_ops *ops = vfe->ops;
+ const struct vfe_hw_ops *ops = vfe->res->hw_ops;
struct media_entity *sensor;
unsigned long flags;
unsigned int frame_skip = 0;
@@ -545,7 +545,7 @@ static void vfe_isr_reg_update(struct vfe_device *vfe, enum vfe_line_id line_id)
unsigned long flags;
spin_lock_irqsave(&vfe->output_lock, flags);
- vfe->ops->reg_update_clear(vfe, line_id);
+ vfe->res->hw_ops->reg_update_clear(vfe, line_id);
output = &line->output;
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index d875237cf244..459c70a4b319 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -296,7 +296,7 @@ int vfe_reset(struct vfe_device *vfe)
reinit_completion(&vfe->reset_complete);
- vfe->ops->global_reset(vfe);
+ vfe->res->hw_ops->global_reset(vfe);
time = wait_for_completion_timeout(&vfe->reset_complete,
msecs_to_jiffies(VFE_RESET_TIMEOUT_MS));
@@ -312,7 +312,7 @@ static void vfe_init_outputs(struct vfe_device *vfe)
{
int i;
- for (i = 0; i < vfe->line_num; i++) {
+ for (i = 0; i < vfe->res->line_num; i++) {
struct vfe_output *output = &vfe->line[i].output;
output->state = VFE_OUTPUT_OFF;
@@ -421,7 +421,7 @@ static int vfe_disable_output(struct vfe_line *line)
spin_lock_irqsave(&vfe->output_lock, flags);
for (i = 0; i < output->wm_num; i++)
- vfe->ops->vfe_wm_stop(vfe, output->wm_idx[i]);
+ vfe->res->hw_ops->vfe_wm_stop(vfe, output->wm_idx[i]);
output->gen2.active_num = 0;
spin_unlock_irqrestore(&vfe->output_lock, flags);
@@ -537,7 +537,7 @@ static int vfe_set_clock_rates(struct vfe_device *vfe)
int i, j;
int ret;
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) {
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
ret = camss_get_pixel_clock(&vfe->line[i].subdev.entity,
&pixel_clock[i]);
if (ret)
@@ -551,7 +551,7 @@ static int vfe_set_clock_rates(struct vfe_device *vfe)
u64 min_rate = 0;
long rate;
- for (j = VFE_LINE_RDI0; j < vfe->line_num; j++) {
+ for (j = VFE_LINE_RDI0; j < vfe->res->line_num; j++) {
u32 tmp;
u8 bpp;
@@ -618,7 +618,7 @@ static int vfe_check_clock_rates(struct vfe_device *vfe)
int i, j;
int ret;
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) {
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
ret = camss_get_pixel_clock(&vfe->line[i].subdev.entity,
&pixel_clock[i]);
if (ret)
@@ -632,7 +632,7 @@ static int vfe_check_clock_rates(struct vfe_device *vfe)
u64 min_rate = 0;
unsigned long rate;
- for (j = VFE_LINE_RDI0; j < vfe->line_num; j++) {
+ for (j = VFE_LINE_RDI0; j < vfe->res->line_num; j++) {
u32 tmp;
u8 bpp;
@@ -675,7 +675,7 @@ int vfe_get(struct vfe_device *vfe)
mutex_lock(&vfe->power_lock);
if (vfe->power_count == 0) {
- ret = vfe->ops->pm_domain_on(vfe);
+ ret = vfe->res->hw_ops->pm_domain_on(vfe);
if (ret < 0)
goto error_pm_domain;
@@ -700,7 +700,7 @@ int vfe_get(struct vfe_device *vfe)
vfe_init_outputs(vfe);
- vfe->ops->hw_version(vfe);
+ vfe->res->hw_ops->hw_version(vfe);
} else {
ret = vfe_check_clock_rates(vfe);
if (ret < 0)
@@ -718,7 +718,7 @@ int vfe_get(struct vfe_device *vfe)
error_pm_runtime_get:
pm_runtime_put_sync(vfe->camss->dev);
error_domain_off:
- vfe->ops->pm_domain_off(vfe);
+ vfe->res->hw_ops->pm_domain_off(vfe);
error_pm_domain:
mutex_unlock(&vfe->power_lock);
@@ -740,11 +740,11 @@ void vfe_put(struct vfe_device *vfe)
} else if (vfe->power_count == 1) {
if (vfe->was_streaming) {
vfe->was_streaming = 0;
- vfe->ops->vfe_halt(vfe);
+ vfe->res->hw_ops->vfe_halt(vfe);
}
camss_disable_clocks(vfe->nclocks, vfe->clock);
pm_runtime_put_sync(vfe->camss->dev);
- vfe->ops->pm_domain_off(vfe);
+ vfe->res->hw_ops->pm_domain_off(vfe);
}
vfe->power_count--;
@@ -834,12 +834,12 @@ static int vfe_set_stream(struct v4l2_subdev *sd, int enable)
if (enable) {
line->output.state = VFE_OUTPUT_RESERVED;
- ret = vfe->ops->vfe_enable(line);
+ ret = vfe->res->hw_ops->vfe_enable(line);
if (ret < 0)
dev_err(vfe->camss->dev,
"Failed to enable vfe outputs\n");
} else {
- ret = vfe->ops->vfe_disable(line);
+ ret = vfe->res->hw_ops->vfe_disable(line);
if (ret < 0)
dev_err(vfe->camss->dev,
"Failed to disable vfe outputs\n");
@@ -1376,23 +1376,24 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
int i, j;
int ret;
- vfe->ops = res->ops;
-
- if (!res->line_num)
+ if (!res->vfe.line_num)
return -EINVAL;
+ vfe->res = &res->vfe;
+ vfe->res->hw_ops->subdev_init(dev, vfe);
+
/* Power domain */
- if (res->pd_name) {
+ if (res->vfe.pd_name) {
vfe->genpd = dev_pm_domain_attach_by_name(camss->dev,
- res->pd_name);
+ res->vfe.pd_name);
if (IS_ERR(vfe->genpd)) {
ret = PTR_ERR(vfe->genpd);
return ret;
}
}
- if (!vfe->genpd && res->has_pd) {
+ if (!vfe->genpd && res->vfe.has_pd) {
/*
* Legacy magic index.
* Requires
@@ -1409,9 +1410,6 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
return PTR_ERR(vfe->genpd);
}
- vfe->line_num = res->line_num;
- vfe->ops->subdev_init(dev, vfe);
-
/* Memory */
vfe->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]);
@@ -1429,7 +1427,7 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
vfe->irq = ret;
snprintf(vfe->irq_name, sizeof(vfe->irq_name), "%s_%s%d",
dev_name(dev), MSM_VFE_NAME, id);
- ret = devm_request_irq(dev, vfe->irq, vfe->ops->isr,
+ ret = devm_request_irq(dev, vfe->irq, vfe->res->hw_ops->isr,
IRQF_TRIGGER_RISING, vfe->irq_name, vfe);
if (ret < 0) {
dev_err(dev, "request_irq failed: %d\n", ret);
@@ -1488,7 +1486,7 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
vfe->id = id;
vfe->reg_update = 0;
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) {
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
struct vfe_line *l = &vfe->line[i];
l->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
@@ -1636,7 +1634,7 @@ int msm_vfe_register_entities(struct vfe_device *vfe,
int ret;
int i;
- for (i = 0; i < vfe->line_num; i++) {
+ for (i = 0; i < vfe->res->line_num; i++) {
char name[32];
sd = &vfe->line[i].subdev;
@@ -1743,7 +1741,7 @@ void msm_vfe_unregister_entities(struct vfe_device *vfe)
mutex_destroy(&vfe->power_lock);
mutex_destroy(&vfe->stream_lock);
- for (i = 0; i < vfe->line_num; i++) {
+ for (i = 0; i < vfe->res->line_num; i++) {
struct v4l2_subdev *sd = &vfe->line[i].subdev;
struct camss_video *video_out = &vfe->line[i].video_out;
@@ -1755,5 +1753,5 @@ void msm_vfe_unregister_entities(struct vfe_device *vfe)
bool vfe_is_lite(struct vfe_device *vfe)
{
- return vfe->camss->res->vfe_res[vfe->id].is_lite;
+ return vfe->camss->res->vfe_res[vfe->id].vfe.is_lite;
}
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h
index 0572c9b08e11..87fc159c48cc 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.h
+++ b/drivers/media/platform/qcom/camss/camss-vfe.h
@@ -126,6 +126,14 @@ struct vfe_isr_ops {
void (*wm_done)(struct vfe_device *vfe, u8 wm);
};
+struct vfe_subdev_resources {
+ bool is_lite;
+ u8 line_num;
+ bool has_pd;
+ char *pd_name;
+ const struct vfe_hw_ops *hw_ops;
+};
+
struct vfe_device {
struct camss *camss;
u8 id;
@@ -143,10 +151,9 @@ struct vfe_device {
spinlock_t output_lock;
enum vfe_line_id wm_output_map[MSM_VFE_IMAGE_MASTERS_NUM];
struct vfe_line line[VFE_LINE_NUM_MAX];
- u8 line_num;
u32 reg_update;
u8 was_streaming;
- const struct vfe_hw_ops *ops;
+ const struct vfe_subdev_resources *res;
const struct vfe_hw_ops_gen1 *ops_gen1;
struct vfe_isr_ops isr_ops;
struct camss_video_ops video_ops;
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index 1923615f0eea..e4ae81dc9a15 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -43,7 +43,10 @@ static const struct camss_subdev_resources csiphy_res_8x16[] = {
{ 100000000, 200000000 } },
.reg = { "csiphy0", "csiphy0_clk_mux" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_2ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_2ph_1_0
+ }
},
/* CSIPHY1 */
@@ -56,7 +59,10 @@ static const struct camss_subdev_resources csiphy_res_8x16[] = {
{ 100000000, 200000000 } },
.reg = { "csiphy1", "csiphy1_clk_mux" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_2ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_2ph_1_0
+ }
}
};
@@ -76,7 +82,10 @@ static const struct camss_subdev_resources csid_res_8x16[] = {
{ 0 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_4_1,
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_4_1
+ }
},
/* CSID1 */
@@ -94,7 +103,10 @@ static const struct camss_subdev_resources csid_res_8x16[] = {
{ 0 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_4_1,
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_4_1
+ }
},
};
@@ -105,8 +117,8 @@ static const struct camss_subdev_resources ispif_res_8x16 = {
"csi1", "csi1_pix", "csi1_rdi" },
.clock_for_reset = { "vfe0", "csi_vfe0" },
.reg = { "ispif", "csi_clk_mux" },
- .interrupt = { "ispif" }
-
+ .interrupt = { "ispif" },
+ .type = CAMSS_SUBDEV_TYPE_ISPIF
};
static const struct camss_subdev_resources vfe_res_8x16[] = {
@@ -128,8 +140,11 @@ static const struct camss_subdev_resources vfe_res_8x16[] = {
{ 0 } },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .line_num = 3,
- .ops = &vfe_ops_4_1
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .line_num = 3,
+ .hw_ops = &vfe_ops_4_1
+ }
}
};
@@ -144,7 +159,10 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
{ 100000000, 200000000, 266666667 } },
.reg = { "csiphy0", "csiphy0_clk_mux" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY1 */
@@ -157,7 +175,10 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
{ 100000000, 200000000, 266666667 } },
.reg = { "csiphy1", "csiphy1_clk_mux" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY2 */
@@ -170,7 +191,10 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
{ 100000000, 200000000, 266666667 } },
.reg = { "csiphy2", "csiphy2_clk_mux" },
.interrupt = { "csiphy2" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
}
};
@@ -190,7 +214,10 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
{ 0 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_4_7,
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID1 */
@@ -208,7 +235,10 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
{ 0 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_4_7,
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID2 */
@@ -226,7 +256,10 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
{ 0 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
- .ops = &csid_ops_4_7,
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID3 */
@@ -244,7 +277,10 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
{ 0 } },
.reg = { "csid3" },
.interrupt = { "csid3" },
- .ops = &csid_ops_4_7,
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
}
};
@@ -257,7 +293,8 @@ static const struct camss_subdev_resources ispif_res_8x96 = {
"csi3", "csi3_pix", "csi3_rdi" },
.clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" },
.reg = { "ispif", "csi_clk_mux" },
- .interrupt = { "ispif" }
+ .interrupt = { "ispif" },
+ .type = CAMSS_SUBDEV_TYPE_ISPIF
};
static const struct camss_subdev_resources vfe_res_8x96[] = {
@@ -277,9 +314,12 @@ static const struct camss_subdev_resources vfe_res_8x96[] = {
{ 0 } },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_4_7
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_4_7
+ }
},
/* VFE1 */
@@ -298,9 +338,12 @@ static const struct camss_subdev_resources vfe_res_8x96[] = {
{ 0 } },
.reg = { "vfe1" },
.interrupt = { "vfe1" },
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_4_7
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_4_7
+ }
}
};
@@ -317,7 +360,10 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
{ 0 } },
.reg = { "csiphy0", "csiphy0_clk_mux" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY1 */
@@ -332,7 +378,10 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
{ 0 } },
.reg = { "csiphy1", "csiphy1_clk_mux" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY2 */
@@ -347,7 +396,10 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
{ 0 } },
.reg = { "csiphy2", "csiphy2_clk_mux" },
.interrupt = { "csiphy2" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
}
};
@@ -370,7 +422,10 @@ static const struct camss_subdev_resources csid_res_660[] = {
{ 0 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_4_7,
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID1 */
@@ -391,7 +446,10 @@ static const struct camss_subdev_resources csid_res_660[] = {
{ 0 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_4_7,
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID2 */
@@ -412,7 +470,10 @@ static const struct camss_subdev_resources csid_res_660[] = {
{ 0 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
- .ops = &csid_ops_4_7,
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID3 */
@@ -433,7 +494,10 @@ static const struct camss_subdev_resources csid_res_660[] = {
{ 0 } },
.reg = { "csid3" },
.interrupt = { "csid3" },
- .ops = &csid_ops_4_7,
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
}
};
@@ -446,7 +510,8 @@ static const struct camss_subdev_resources ispif_res_660 = {
"csi3", "csi3_pix", "csi3_rdi" },
.clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" },
.reg = { "ispif", "csi_clk_mux" },
- .interrupt = { "ispif" }
+ .interrupt = { "ispif" },
+ .type = CAMSS_SUBDEV_TYPE_ISPIF
};
static const struct camss_subdev_resources vfe_res_660[] = {
@@ -469,9 +534,12 @@ static const struct camss_subdev_resources vfe_res_660[] = {
{ 0 } },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_4_8
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_4_8
+ }
},
/* VFE1 */
@@ -493,9 +561,12 @@ static const struct camss_subdev_resources vfe_res_660[] = {
{ 0 } },
.reg = { "vfe1" },
.interrupt = { "vfe1" },
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_4_8
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_4_8
+ }
}
};
@@ -516,7 +587,10 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
{ 19200000, 240000000, 269333333 } },
.reg = { "csiphy0" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY1 */
@@ -535,7 +609,10 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
{ 19200000, 240000000, 269333333 } },
.reg = { "csiphy1" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY2 */
@@ -554,7 +631,10 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
{ 19200000, 240000000, 269333333 } },
.reg = { "csiphy2" },
.interrupt = { "csiphy2" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY3 */
@@ -573,7 +653,10 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
{ 19200000, 240000000, 269333333 } },
.reg = { "csiphy3" },
.interrupt = { "csiphy3" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
}
};
@@ -596,7 +679,10 @@ static const struct camss_subdev_resources csid_res_845[] = {
{ 384000000 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_gen2
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID1 */
@@ -617,7 +703,10 @@ static const struct camss_subdev_resources csid_res_845[] = {
{ 384000000 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_gen2
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID2 */
@@ -638,8 +727,11 @@ static const struct camss_subdev_resources csid_res_845[] = {
{ 384000000 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
}
};
@@ -662,9 +754,12 @@ static const struct camss_subdev_resources vfe_res_845[] = {
{ 384000000 } },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .line_num = 4,
- .has_pd = true,
- .ops = &vfe_ops_170
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .line_num = 4,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE1 */
@@ -685,9 +780,12 @@ static const struct camss_subdev_resources vfe_res_845[] = {
{ 384000000 } },
.reg = { "vfe1" },
.interrupt = { "vfe1" },
- .line_num = 4,
- .has_pd = true,
- .ops = &vfe_ops_170
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .line_num = 4,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE-lite */
@@ -707,9 +805,12 @@ static const struct camss_subdev_resources vfe_res_845[] = {
{ 384000000 } },
.reg = { "vfe_lite" },
.interrupt = { "vfe_lite" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_170
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_170
+ }
}
};
@@ -722,7 +823,10 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy0" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY1 */
{
@@ -732,7 +836,10 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy1" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY2 */
{
@@ -742,7 +849,10 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy2" },
.interrupt = { "csiphy2" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY3 */
{
@@ -752,7 +862,10 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy3" },
.interrupt = { "csiphy3" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY4 */
{
@@ -762,7 +875,10 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy4" },
.interrupt = { "csiphy4" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY5 */
{
@@ -772,7 +888,10 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy5" },
.interrupt = { "csiphy5" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
}
};
@@ -788,7 +907,10 @@ static const struct camss_subdev_resources csid_res_8250[] = {
{ 0 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_gen2
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID1 */
{
@@ -801,7 +923,10 @@ static const struct camss_subdev_resources csid_res_8250[] = {
{ 0 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_gen2
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID2 */
{
@@ -813,8 +938,11 @@ static const struct camss_subdev_resources csid_res_8250[] = {
{ 0 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID3 */
{
@@ -826,8 +954,11 @@ static const struct camss_subdev_resources csid_res_8250[] = {
{ 0 } },
.reg = { "csid3" },
.interrupt = { "csid3" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .type = CAMSS_SUBDEV_TYPE_CSID,
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
}
};
@@ -849,10 +980,13 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
{ 0 } },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .pd_name = "ife0",
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_480
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .pd_name = "ife0",
+ .hw_ops = &vfe_ops_480
+ }
},
/* VFE1 */
{
@@ -871,10 +1005,13 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
{ 0 } },
.reg = { "vfe1" },
.interrupt = { "vfe1" },
- .pd_name = "ife1",
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_480
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .pd_name = "ife1",
+ .hw_ops = &vfe_ops_480
+ }
},
/* VFE2 (lite) */
{
@@ -892,9 +1029,12 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
{ 0 } },
.reg = { "vfe_lite0" },
.interrupt = { "vfe_lite0" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_480
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_480
+ }
},
/* VFE3 (lite) */
{
@@ -912,9 +1052,12 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
{ 0 } },
.reg = { "vfe_lite1" },
.interrupt = { "vfe_lite1" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_480
+ .type = CAMSS_SUBDEV_TYPE_VFE,
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_480
+ }
},
};
@@ -950,7 +1093,10 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
{ 300000000 } },
.reg = { "csiphy0" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_3ph_1_0
+ .type = CAMSS_SUBDEV_TYPE_CSIPHY,
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY1 */
{
@@ -960,7 +1106,9 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
{ 300000000 } },
.reg = { "csiphy1" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY2 */
{
@@ -970,7 +1118,9 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
{ 300000000 } },
.reg = { "csiphy2" },
.interrupt = { "csiphy2" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY3 */
{
@@ -980,7 +1130,9 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
{ 300000000 } },
.reg = { "csiphy3" },
.interrupt = { "csiphy3" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
};
@@ -995,7 +1147,9 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID1 */
{
@@ -1007,7 +1161,9 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID2 */
{
@@ -1019,7 +1175,9 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID3 */
{
@@ -1031,7 +1189,9 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 } },
.reg = { "csid3" },
.interrupt = { "csid3" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID_LITE0 */
{
@@ -1042,8 +1202,10 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 }, },
.reg = { "csid0_lite" },
.interrupt = { "csid0_lite" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID_LITE1 */
{
@@ -1054,8 +1216,10 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 }, },
.reg = { "csid1_lite" },
.interrupt = { "csid1_lite" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID_LITE2 */
{
@@ -1066,8 +1230,10 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 }, },
.reg = { "csid2_lite" },
.interrupt = { "csid2_lite" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID_LITE3 */
{
@@ -1078,8 +1244,10 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 }, },
.reg = { "csid3_lite" },
.interrupt = { "csid3_lite" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
}
};
@@ -1096,9 +1264,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 0 }, },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .pd_name = "ife0",
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .line_num = 4,
+ .pd_name = "ife0",
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE1 */
{
@@ -1112,9 +1282,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 0 }, },
.reg = { "vfe1" },
.interrupt = { "vfe1" },
- .pd_name = "ife1",
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .line_num = 4,
+ .pd_name = "ife1",
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE2 */
{
@@ -1128,9 +1300,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 0 }, },
.reg = { "vfe2" },
.interrupt = { "vfe2" },
- .pd_name = "ife2",
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .line_num = 4,
+ .pd_name = "ife2",
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE3 */
{
@@ -1144,9 +1318,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 0 }, },
.reg = { "vfe3" },
.interrupt = { "vfe3" },
- .pd_name = "ife3",
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .line_num = 4,
+ .pd_name = "ife3",
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE_LITE_0 */
{
@@ -1159,9 +1335,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 320000000, 400000000, 480000000, 600000000 }, },
.reg = { "vfe_lite0" },
.interrupt = { "vfe_lite0" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE_LITE_1 */
{
@@ -1174,9 +1352,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 320000000, 400000000, 480000000, 600000000 }, },
.reg = { "vfe_lite1" },
.interrupt = { "vfe_lite1" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE_LITE_2 */
{
@@ -1189,9 +1369,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 320000000, 400000000, 480000000, 600000000, }, },
.reg = { "vfe_lite2" },
.interrupt = { "vfe_lite2" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE_LITE_3 */
{
@@ -1204,9 +1386,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 320000000, 400000000, 480000000, 600000000 }, },
.reg = { "vfe_lite3" },
.interrupt = { "vfe_lite3" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_170
+ }
},
};
@@ -1375,7 +1559,7 @@ int camss_pm_domain_on(struct camss *camss, int id)
if (id < camss->res->vfe_num) {
struct vfe_device *vfe = &camss->vfe[id];
- ret = vfe->ops->pm_domain_on(vfe);
+ ret = vfe->res->hw_ops->pm_domain_on(vfe);
}
return ret;
@@ -1386,7 +1570,7 @@ void camss_pm_domain_off(struct camss *camss, int id)
if (id < camss->res->vfe_num) {
struct vfe_device *vfe = &camss->vfe[id];
- vfe->ops->pm_domain_off(vfe);
+ vfe->res->hw_ops->pm_domain_off(vfe);
}
}
@@ -1628,7 +1812,7 @@ static int camss_register_entities(struct camss *camss)
for (i = 0; i < camss->ispif->line_num; i++)
for (k = 0; k < camss->res->vfe_num; k++)
- for (j = 0; j < camss->vfe[k].line_num; j++) {
+ for (j = 0; j < camss->vfe[k].res->line_num; j++) {
struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev;
struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
@@ -1649,7 +1833,7 @@ static int camss_register_entities(struct camss *camss)
} else {
for (i = 0; i < camss->res->csid_num; i++)
for (k = 0; k < camss->res->vfe_num; k++)
- for (j = 0; j < camss->vfe[k].line_num; j++) {
+ for (j = 0; j < camss->vfe[k].res->line_num; j++) {
struct v4l2_subdev *csid = &camss->csid[i].subdev;
struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
@@ -1810,7 +1994,7 @@ static int camss_configure_pd(struct camss *camss)
/* count the # of VFEs which have flagged power-domain */
for (vfepd_num = i = 0; i < camss->res->vfe_num; i++) {
- if (res->vfe_res[i].has_pd)
+ if (res->vfe_res[i].vfe.has_pd)
vfepd_num++;
}
diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
index ac15fe23a702..2477821dfd85 100644
--- a/drivers/media/platform/qcom/camss/camss.h
+++ b/drivers/media/platform/qcom/camss/camss.h
@@ -41,6 +41,13 @@
#define CAMSS_RES_MAX 17
+enum camss_subdev_type {
+ CAMSS_SUBDEV_TYPE_CSIPHY,
+ CAMSS_SUBDEV_TYPE_CSID,
+ CAMSS_SUBDEV_TYPE_ISPIF,
+ CAMSS_SUBDEV_TYPE_VFE,
+};
+
struct camss_subdev_resources {
char *regulators[CAMSS_RES_MAX];
char *clock[CAMSS_RES_MAX];
@@ -48,11 +55,12 @@ struct camss_subdev_resources {
u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX];
char *reg[CAMSS_RES_MAX];
char *interrupt[CAMSS_RES_MAX];
- char *pd_name;
- u8 line_num;
- bool has_pd;
- bool is_lite;
- const void *ops;
+ enum camss_subdev_type type;
+ union {
+ struct csiphy_subdev_resources csiphy;
+ struct csid_subdev_resources csid;
+ struct vfe_subdev_resources vfe;
+ };
};
struct icc_bw_tbl {
--
2.17.1
From: Radoslav Tsvetkov <[email protected]>
Following the example of VFE, move all formats of the decoder
to camss-csid.c and attach them to the subdevices resources.
Signed-off-by: Radoslav Tsvetkov <[email protected]>
Signed-off-by: Gjorgji Rosikopulos <[email protected]>
---
.../platform/qcom/camss/camss-csid-4-1.c | 132 +----
.../platform/qcom/camss/camss-csid-4-7.c | 160 +-----
.../platform/qcom/camss/camss-csid-gen2.c | 164 +-----
.../media/platform/qcom/camss/camss-csid.c | 474 +++++++++++++++++-
.../media/platform/qcom/camss/camss-csid.h | 24 +-
drivers/media/platform/qcom/camss/camss.c | 75 ++-
6 files changed, 538 insertions(+), 491 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-csid-4-1.c b/drivers/media/platform/qcom/camss/camss-csid-4-1.c
index dd49a40e6a70..c95861420502 100644
--- a/drivers/media/platform/qcom/camss/camss-csid-4-1.c
+++ b/drivers/media/platform/qcom/camss/camss-csid-4-1.c
@@ -45,128 +45,6 @@
#define CAMSS_CSID_TG_DT_n_CGG_1(n) (0x0b0 + 0xc * (n))
#define CAMSS_CSID_TG_DT_n_CGG_2(n) (0x0b4 + 0xc * (n))
-static const struct csid_format csid_formats[] = {
- {
- MEDIA_BUS_FMT_UYVY8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_VYUY8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_YUYV8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_YVYU8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_SBGGR8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SBGGR10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SBGGR12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_Y10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
-};
-
static void csid_configure_stream(struct csid_device *csid, u8 enable)
{
struct csid_testgen_config *tg = &csid->testgen;
@@ -174,7 +52,7 @@ static void csid_configure_stream(struct csid_device *csid, u8 enable)
if (enable) {
struct v4l2_mbus_framefmt *input_format;
- const struct csid_format *format;
+ const struct csid_format_info *format;
u8 vc = 0; /* Virtual Channel 0 */
u8 cid = vc * 4; /* id of Virtual Channel and Data Type set */
u8 dt_shift;
@@ -184,7 +62,8 @@ static void csid_configure_stream(struct csid_device *csid, u8 enable)
u32 num_lines, num_bytes_per_line;
input_format = &csid->fmt[MSM_CSID_PAD_SRC];
- format = csid_get_fmt_entry(csid->formats, csid->nformats,
+ format = csid_get_fmt_entry(csid->res->formats->formats,
+ csid->res->formats->nformats,
input_format->code);
num_bytes_per_line = input_format->width * format->bpp * format->spp / 8;
num_lines = input_format->height;
@@ -211,7 +90,8 @@ static void csid_configure_stream(struct csid_device *csid, u8 enable)
struct csid_phy_config *phy = &csid->phy;
input_format = &csid->fmt[MSM_CSID_PAD_SINK];
- format = csid_get_fmt_entry(csid->formats, csid->nformats,
+ format = csid_get_fmt_entry(csid->res->formats->formats,
+ csid->res->formats->nformats,
input_format->code);
val = phy->lane_cnt - 1;
@@ -311,8 +191,6 @@ static u32 csid_src_pad_code(struct csid_device *csid, u32 sink_code,
static void csid_subdev_init(struct csid_device *csid)
{
- csid->formats = csid_formats;
- csid->nformats = ARRAY_SIZE(csid_formats);
csid->testgen.modes = csid_testgen_modes;
csid->testgen.nmodes = CSID_PAYLOAD_MODE_NUM_SUPPORTED_GEN1;
}
diff --git a/drivers/media/platform/qcom/camss/camss-csid-4-7.c b/drivers/media/platform/qcom/camss/camss-csid-4-7.c
index 6b26e036294e..08578a143688 100644
--- a/drivers/media/platform/qcom/camss/camss-csid-4-7.c
+++ b/drivers/media/platform/qcom/camss/camss-csid-4-7.c
@@ -44,156 +44,6 @@
#define CAMSS_CSID_TG_DT_n_CGG_1(n) (0x0b8 + 0xc * (n))
#define CAMSS_CSID_TG_DT_n_CGG_2(n) (0x0bc + 0xc * (n))
-static const struct csid_format csid_formats[] = {
- {
- MEDIA_BUS_FMT_UYVY8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_VYUY8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_YUYV8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_YVYU8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_SBGGR8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SBGGR10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SBGGR12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SBGGR14_1X14,
- DATA_TYPE_RAW_14BIT,
- DECODE_FORMAT_UNCOMPRESSED_14_BIT,
- 14,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG14_1X14,
- DATA_TYPE_RAW_14BIT,
- DECODE_FORMAT_UNCOMPRESSED_14_BIT,
- 14,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG14_1X14,
- DATA_TYPE_RAW_14BIT,
- DECODE_FORMAT_UNCOMPRESSED_14_BIT,
- 14,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB14_1X14,
- DATA_TYPE_RAW_14BIT,
- DECODE_FORMAT_UNCOMPRESSED_14_BIT,
- 14,
- 1,
- },
- {
- MEDIA_BUS_FMT_Y10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
-};
-
static void csid_configure_stream(struct csid_device *csid, u8 enable)
{
struct csid_testgen_config *tg = &csid->testgen;
@@ -203,7 +53,7 @@ static void csid_configure_stream(struct csid_device *csid, u8 enable)
if (enable) {
struct v4l2_mbus_framefmt *input_format;
- const struct csid_format *format;
+ const struct csid_format_info *format;
u8 vc = 0; /* Virtual Channel 0 */
u8 cid = vc * 4; /* id of Virtual Channel and Data Type set */
u8 dt_shift;
@@ -213,7 +63,8 @@ static void csid_configure_stream(struct csid_device *csid, u8 enable)
u32 num_bytes_per_line, num_lines;
input_format = &csid->fmt[MSM_CSID_PAD_SRC];
- format = csid_get_fmt_entry(csid->formats, csid->nformats,
+ format = csid_get_fmt_entry(csid->res->formats->formats,
+ csid->res->formats->nformats,
input_format->code);
num_bytes_per_line = input_format->width * format->bpp * format->spp / 8;
num_lines = input_format->height;
@@ -240,7 +91,8 @@ static void csid_configure_stream(struct csid_device *csid, u8 enable)
struct csid_phy_config *phy = &csid->phy;
input_format = &csid->fmt[MSM_CSID_PAD_SINK];
- format = csid_get_fmt_entry(csid->formats, csid->nformats,
+ format = csid_get_fmt_entry(csid->res->formats->formats,
+ csid->res->formats->nformats,
input_format->code);
val = phy->lane_cnt - 1;
@@ -387,8 +239,6 @@ static u32 csid_src_pad_code(struct csid_device *csid, u32 sink_code,
static void csid_subdev_init(struct csid_device *csid)
{
- csid->formats = csid_formats;
- csid->nformats = ARRAY_SIZE(csid_formats);
csid->testgen.modes = csid_testgen_modes;
csid->testgen.nmodes = CSID_PAYLOAD_MODE_NUM_SUPPORTED_GEN1;
}
diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen2.c b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
index b11de4797cca..eb5dabe2639a 100644
--- a/drivers/media/platform/qcom/camss/camss-csid-gen2.c
+++ b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
@@ -176,163 +176,6 @@
#define TPG_COLOR_BOX_CFG_MODE 0
#define TPG_COLOR_BOX_PATTERN_SEL 2
-static const struct csid_format csid_formats[] = {
- {
- MEDIA_BUS_FMT_UYVY8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_VYUY8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_YUYV8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_YVYU8_1X16,
- DATA_TYPE_YUV422_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 2,
- },
- {
- MEDIA_BUS_FMT_SBGGR8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_SBGGR10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_Y8_1X8,
- DATA_TYPE_RAW_8BIT,
- DECODE_FORMAT_UNCOMPRESSED_8_BIT,
- 8,
- 1,
- },
- {
- MEDIA_BUS_FMT_Y10_1X10,
- DATA_TYPE_RAW_10BIT,
- DECODE_FORMAT_UNCOMPRESSED_10_BIT,
- 10,
- 1,
- },
- {
- MEDIA_BUS_FMT_SBGGR12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB12_1X12,
- DATA_TYPE_RAW_12BIT,
- DECODE_FORMAT_UNCOMPRESSED_12_BIT,
- 12,
- 1,
- },
- {
- MEDIA_BUS_FMT_SBGGR14_1X14,
- DATA_TYPE_RAW_14BIT,
- DECODE_FORMAT_UNCOMPRESSED_14_BIT,
- 14,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGBRG14_1X14,
- DATA_TYPE_RAW_14BIT,
- DECODE_FORMAT_UNCOMPRESSED_14_BIT,
- 14,
- 1,
- },
- {
- MEDIA_BUS_FMT_SGRBG14_1X14,
- DATA_TYPE_RAW_14BIT,
- DECODE_FORMAT_UNCOMPRESSED_14_BIT,
- 14,
- 1,
- },
- {
- MEDIA_BUS_FMT_SRGGB14_1X14,
- DATA_TYPE_RAW_14BIT,
- DECODE_FORMAT_UNCOMPRESSED_14_BIT,
- 14,
- 1,
- },
-};
-
static void __csid_configure_stream(struct csid_device *csid, u8 enable, u8 vc)
{
struct csid_testgen_config *tg = &csid->testgen;
@@ -341,8 +184,9 @@ static void __csid_configure_stream(struct csid_device *csid, u8 enable, u8 vc)
u8 lane_cnt = csid->phy.lane_cnt;
/* Source pads matching RDI channels on hardware. Pad 1 -> RDI0, Pad 2 -> RDI1, etc. */
struct v4l2_mbus_framefmt *input_format = &csid->fmt[MSM_CSID_PAD_FIRST_SRC + vc];
- const struct csid_format *format = csid_get_fmt_entry(csid->formats, csid->nformats,
- input_format->code);
+ const struct csid_format_info *format = csid_get_fmt_entry(csid->res->formats->formats,
+ csid->res->formats->nformats,
+ input_format->code);
if (!lane_cnt)
lane_cnt = 4;
@@ -612,8 +456,6 @@ static u32 csid_src_pad_code(struct csid_device *csid, u32 sink_code,
static void csid_subdev_init(struct csid_device *csid)
{
- csid->formats = csid_formats;
- csid->nformats = ARRAY_SIZE(csid_formats);
csid->testgen.modes = csid_testgen_modes;
csid->testgen.nmodes = CSID_PAYLOAD_MODE_NUM_SUPPORTED_GEN2;
}
diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index d1a22e07fdb6..5b23f5b8746d 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -45,6 +45,450 @@ const char * const csid_testgen_modes[] = {
NULL
};
+static const struct csid_format_info formats_4_1[] = {
+ {
+ MEDIA_BUS_FMT_UYVY8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_VYUY8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_YUYV8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_YVYU8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_Y10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+};
+
+static const struct csid_format_info formats_4_7[] = {
+ {
+ MEDIA_BUS_FMT_UYVY8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_VYUY8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_YUYV8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_YVYU8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR14_1X14,
+ DATA_TYPE_RAW_14BIT,
+ DECODE_FORMAT_UNCOMPRESSED_14_BIT,
+ 14,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG14_1X14,
+ DATA_TYPE_RAW_14BIT,
+ DECODE_FORMAT_UNCOMPRESSED_14_BIT,
+ 14,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG14_1X14,
+ DATA_TYPE_RAW_14BIT,
+ DECODE_FORMAT_UNCOMPRESSED_14_BIT,
+ 14,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB14_1X14,
+ DATA_TYPE_RAW_14BIT,
+ DECODE_FORMAT_UNCOMPRESSED_14_BIT,
+ 14,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_Y10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+};
+
+static const struct csid_format_info formats_gen2[] = {
+ {
+ MEDIA_BUS_FMT_UYVY8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_VYUY8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_YUYV8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_YVYU8_1X16,
+ DATA_TYPE_YUV422_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 2,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_Y8_1X8,
+ DATA_TYPE_RAW_8BIT,
+ DECODE_FORMAT_UNCOMPRESSED_8_BIT,
+ 8,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_Y10_1X10,
+ DATA_TYPE_RAW_10BIT,
+ DECODE_FORMAT_UNCOMPRESSED_10_BIT,
+ 10,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB12_1X12,
+ DATA_TYPE_RAW_12BIT,
+ DECODE_FORMAT_UNCOMPRESSED_12_BIT,
+ 12,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SBGGR14_1X14,
+ DATA_TYPE_RAW_14BIT,
+ DECODE_FORMAT_UNCOMPRESSED_14_BIT,
+ 14,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGBRG14_1X14,
+ DATA_TYPE_RAW_14BIT,
+ DECODE_FORMAT_UNCOMPRESSED_14_BIT,
+ 14,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SGRBG14_1X14,
+ DATA_TYPE_RAW_14BIT,
+ DECODE_FORMAT_UNCOMPRESSED_14_BIT,
+ 14,
+ 1,
+ },
+ {
+ MEDIA_BUS_FMT_SRGGB14_1X14,
+ DATA_TYPE_RAW_14BIT,
+ DECODE_FORMAT_UNCOMPRESSED_14_BIT,
+ 14,
+ 1,
+ },
+};
+
+const struct csid_formats csid_formats_4_1 = {
+ .nformats = ARRAY_SIZE(formats_4_1),
+ .formats = formats_4_1
+};
+
+const struct csid_formats csid_formats_4_7 = {
+ .nformats = ARRAY_SIZE(formats_4_7),
+ .formats = formats_4_7
+};
+
+const struct csid_formats csid_formats_gen2 = {
+ .nformats = ARRAY_SIZE(formats_gen2),
+ .formats = formats_gen2
+};
+
u32 csid_find_code(u32 *codes, unsigned int ncodes,
unsigned int match_format_idx, u32 match_code)
{
@@ -65,9 +509,9 @@ u32 csid_find_code(u32 *codes, unsigned int ncodes,
return codes[0];
}
-const struct csid_format *csid_get_fmt_entry(const struct csid_format *formats,
- unsigned int nformats,
- u32 code)
+const struct csid_format_info *csid_get_fmt_entry(const struct csid_format_info *formats,
+ unsigned int nformats,
+ u32 code)
{
unsigned int i;
@@ -87,12 +531,12 @@ const struct csid_format *csid_get_fmt_entry(const struct csid_format *formats,
static int csid_set_clock_rates(struct csid_device *csid)
{
struct device *dev = csid->camss->dev;
- const struct csid_format *fmt;
+ const struct csid_format_info *fmt;
s64 link_freq;
int i, j;
int ret;
- fmt = csid_get_fmt_entry(csid->formats, csid->nformats,
+ fmt = csid_get_fmt_entry(csid->res->formats->formats, csid->res->formats->nformats,
csid->fmt[MSM_CSIPHY_PAD_SINK].code);
link_freq = camss_get_link_freq(&csid->subdev.entity, fmt->bpp,
csid->phy.lane_cnt);
@@ -301,12 +745,12 @@ static void csid_try_format(struct csid_device *csid,
case MSM_CSID_PAD_SINK:
/* Set format on sink pad */
- for (i = 0; i < csid->nformats; i++)
- if (fmt->code == csid->formats[i].code)
+ for (i = 0; i < csid->res->formats->nformats; i++)
+ if (fmt->code == csid->res->formats->formats[i].code)
break;
/* If not found, use UYVY as default */
- if (i >= csid->nformats)
+ if (i >= csid->res->formats->nformats)
fmt->code = MEDIA_BUS_FMT_UYVY8_1X16;
fmt->width = clamp_t(u32, fmt->width, 1, 8191);
@@ -330,12 +774,12 @@ static void csid_try_format(struct csid_device *csid,
/* Test generator is enabled, set format on source */
/* pad to allow test generator usage */
- for (i = 0; i < csid->nformats; i++)
- if (csid->formats[i].code == fmt->code)
+ for (i = 0; i < csid->res->formats->nformats; i++)
+ if (csid->res->formats->formats[i].code == fmt->code)
break;
/* If not found, use UYVY as default */
- if (i >= csid->nformats)
+ if (i >= csid->res->formats->nformats)
fmt->code = MEDIA_BUS_FMT_UYVY8_1X16;
fmt->width = clamp_t(u32, fmt->width, 1, 8191);
@@ -363,10 +807,10 @@ static int csid_enum_mbus_code(struct v4l2_subdev *sd,
struct csid_device *csid = v4l2_get_subdevdata(sd);
if (code->pad == MSM_CSID_PAD_SINK) {
- if (code->index >= csid->nformats)
+ if (code->index >= csid->res->formats->nformats)
return -EINVAL;
- code->code = csid->formats[code->index].code;
+ code->code = csid->res->formats->formats[code->index].code;
} else {
if (csid->testgen_mode->cur.val == 0) {
struct v4l2_mbus_framefmt *sink_fmt;
@@ -380,10 +824,10 @@ static int csid_enum_mbus_code(struct v4l2_subdev *sd,
if (!code->code)
return -EINVAL;
} else {
- if (code->index >= csid->nformats)
+ if (code->index >= csid->res->formats->nformats)
return -EINVAL;
- code->code = csid->formats[code->index].code;
+ code->code = csid->res->formats->formats[code->index].code;
}
}
diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media/platform/qcom/camss/camss-csid.h
index 8d2971aa9ef8..0e385d17c250 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.h
+++ b/drivers/media/platform/qcom/camss/camss-csid.h
@@ -67,7 +67,7 @@ enum csid_testgen_mode {
CSID_PAYLOAD_MODE_NUM_SUPPORTED_GEN2 = 9, /* excluding disabled */
};
-struct csid_format {
+struct csid_format_info {
u32 code;
u8 data_type;
u8 decode_format;
@@ -75,6 +75,11 @@ struct csid_format {
u8 spp; /* bus samples per pixel */
};
+struct csid_formats {
+ unsigned int nformats;
+ const struct csid_format_info *formats;
+};
+
struct csid_testgen_config {
enum csid_testgen_mode mode;
const char * const*modes;
@@ -152,6 +157,7 @@ struct csid_hw_ops {
struct csid_subdev_resources {
bool is_lite;
const struct csid_hw_ops *hw_ops;
+ const struct csid_formats *formats;
};
struct csid_device {
@@ -172,8 +178,6 @@ struct csid_device {
struct v4l2_mbus_framefmt fmt[MSM_CSID_PADS_NUM];
struct v4l2_ctrl_handler ctrls;
struct v4l2_ctrl *testgen_mode;
- const struct csid_format *formats;
- unsigned int nformats;
const struct csid_subdev_resources *res;
};
@@ -193,16 +197,16 @@ u32 csid_find_code(u32 *codes, unsigned int ncode,
unsigned int match_format_idx, u32 match_code);
/*
- * csid_get_fmt_entry - Find csid_format entry with matching format code
- * @formats: Array of format csid_format entries
+ * csid_get_fmt_entry - Find csid_format_info entry with matching format code
+ * @formats: Array of format csid_format_info entries
* @nformats: Length of @nformats array
* @code: Desired format code
*
* Return formats[0] on failure to find code
*/
-const struct csid_format *csid_get_fmt_entry(const struct csid_format *formats,
- unsigned int nformats,
- u32 code);
+const struct csid_format_info *csid_get_fmt_entry(const struct csid_format_info *formats,
+ unsigned int nformats,
+ u32 code);
int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
const struct camss_subdev_resources *res, u8 id);
@@ -216,6 +220,10 @@ void msm_csid_get_csid_id(struct media_entity *entity, u8 *id);
extern const char * const csid_testgen_modes[];
+extern const struct csid_formats csid_formats_4_1;
+extern const struct csid_formats csid_formats_4_7;
+extern const struct csid_formats csid_formats_gen2;
+
extern const struct csid_hw_ops csid_ops_4_1;
extern const struct csid_hw_ops csid_ops_4_7;
extern const struct csid_hw_ops csid_ops_gen2;
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index f3242d2d9807..efce883d4121 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -84,7 +84,8 @@ static const struct camss_subdev_resources csid_res_8x16[] = {
.interrupt = { "csid0" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_4_1
+ .hw_ops = &csid_ops_4_1,
+ .formats = &csid_formats_4_1
}
},
@@ -105,7 +106,8 @@ static const struct camss_subdev_resources csid_res_8x16[] = {
.interrupt = { "csid1" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_4_1
+ .hw_ops = &csid_ops_4_1,
+ .formats = &csid_formats_4_1
}
},
};
@@ -218,7 +220,8 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
.interrupt = { "csid0" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_4_7
+ .hw_ops = &csid_ops_4_7,
+ .formats = &csid_formats_4_7
}
},
@@ -239,7 +242,8 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
.interrupt = { "csid1" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_4_7
+ .hw_ops = &csid_ops_4_7,
+ .formats = &csid_formats_4_7
}
},
@@ -260,7 +264,8 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
.interrupt = { "csid2" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_4_7
+ .hw_ops = &csid_ops_4_7,
+ .formats = &csid_formats_4_7
}
},
@@ -281,7 +286,8 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
.interrupt = { "csid3" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_4_7
+ .hw_ops = &csid_ops_4_7,
+ .formats = &csid_formats_4_7
}
}
};
@@ -430,7 +436,8 @@ static const struct camss_subdev_resources csid_res_660[] = {
.interrupt = { "csid0" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_4_7
+ .hw_ops = &csid_ops_4_7,
+ .formats = &csid_formats_4_7
}
},
@@ -454,7 +461,8 @@ static const struct camss_subdev_resources csid_res_660[] = {
.interrupt = { "csid1" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_4_7
+ .hw_ops = &csid_ops_4_7,
+ .formats = &csid_formats_4_7
}
},
@@ -478,7 +486,8 @@ static const struct camss_subdev_resources csid_res_660[] = {
.interrupt = { "csid2" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_4_7
+ .hw_ops = &csid_ops_4_7,
+ .formats = &csid_formats_4_7
}
},
@@ -502,7 +511,8 @@ static const struct camss_subdev_resources csid_res_660[] = {
.interrupt = { "csid3" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_4_7
+ .hw_ops = &csid_ops_4_7,
+ .formats = &csid_formats_4_7
}
}
};
@@ -691,7 +701,8 @@ static const struct camss_subdev_resources csid_res_845[] = {
.interrupt = { "csid0" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
@@ -715,7 +726,8 @@ static const struct camss_subdev_resources csid_res_845[] = {
.interrupt = { "csid1" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
@@ -740,7 +752,8 @@ static const struct camss_subdev_resources csid_res_845[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.is_lite = true,
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
}
};
@@ -925,7 +938,8 @@ static const struct camss_subdev_resources csid_res_8250[] = {
.interrupt = { "csid0" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
/* CSID1 */
@@ -941,7 +955,8 @@ static const struct camss_subdev_resources csid_res_8250[] = {
.interrupt = { "csid1" },
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
/* CSID2 */
@@ -957,7 +972,8 @@ static const struct camss_subdev_resources csid_res_8250[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.is_lite = true,
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
/* CSID3 */
@@ -973,7 +989,8 @@ static const struct camss_subdev_resources csid_res_8250[] = {
.type = CAMSS_SUBDEV_TYPE_CSID,
.csid = {
.is_lite = true,
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
}
};
@@ -1172,7 +1189,8 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.reg = { "csid0" },
.interrupt = { "csid0" },
.csid = {
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
/* CSID1 */
@@ -1186,7 +1204,8 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.reg = { "csid1" },
.interrupt = { "csid1" },
.csid = {
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
/* CSID2 */
@@ -1200,7 +1219,8 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.reg = { "csid2" },
.interrupt = { "csid2" },
.csid = {
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
/* CSID3 */
@@ -1214,7 +1234,8 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.reg = { "csid3" },
.interrupt = { "csid3" },
.csid = {
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
/* CSID_LITE0 */
@@ -1228,7 +1249,8 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.interrupt = { "csid0_lite" },
.csid = {
.is_lite = true,
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
/* CSID_LITE1 */
@@ -1242,7 +1264,8 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.interrupt = { "csid1_lite" },
.csid = {
.is_lite = true,
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
/* CSID_LITE2 */
@@ -1256,7 +1279,8 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.interrupt = { "csid2_lite" },
.csid = {
.is_lite = true,
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
},
/* CSID_LITE3 */
@@ -1270,7 +1294,8 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
.interrupt = { "csid3_lite" },
.csid = {
.is_lite = true,
- .hw_ops = &csid_ops_gen2
+ .hw_ops = &csid_ops_gen2,
+ .formats = &csid_formats_gen2
}
}
};
--
2.17.1
From: Radoslav Tsvetkov <[email protected]>
Following the example of VFE and CSID, attach the CSIPHY
formats to the subdevices resources.
Signed-off-by: Radoslav Tsvetkov <[email protected]>
Signed-off-by: Gjorgji Rosikopulos <[email protected]>
---
.../media/platform/qcom/camss/camss-csiphy.c | 60 ++++++++---------
.../media/platform/qcom/camss/camss-csiphy.h | 17 ++++-
drivers/media/platform/qcom/camss/camss.c | 66 ++++++++++++-------
3 files changed, 85 insertions(+), 58 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
index f26ddf1af9d4..2f7361dfd461 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
@@ -24,12 +24,7 @@
#define MSM_CSIPHY_NAME "msm_csiphy"
-struct csiphy_format {
- u32 code;
- u8 bpp;
-};
-
-static const struct csiphy_format csiphy_formats_8x16[] = {
+static const struct csiphy_format_info formats_8x16[] = {
{ MEDIA_BUS_FMT_UYVY8_1X16, 8 },
{ MEDIA_BUS_FMT_VYUY8_1X16, 8 },
{ MEDIA_BUS_FMT_YUYV8_1X16, 8 },
@@ -49,7 +44,7 @@ static const struct csiphy_format csiphy_formats_8x16[] = {
{ MEDIA_BUS_FMT_Y10_1X10, 10 },
};
-static const struct csiphy_format csiphy_formats_8x96[] = {
+static const struct csiphy_format_info formats_8x96[] = {
{ MEDIA_BUS_FMT_UYVY8_1X16, 8 },
{ MEDIA_BUS_FMT_VYUY8_1X16, 8 },
{ MEDIA_BUS_FMT_YUYV8_1X16, 8 },
@@ -73,7 +68,7 @@ static const struct csiphy_format csiphy_formats_8x96[] = {
{ MEDIA_BUS_FMT_Y10_1X10, 10 },
};
-static const struct csiphy_format csiphy_formats_sdm845[] = {
+static const struct csiphy_format_info formats_sdm845[] = {
{ MEDIA_BUS_FMT_UYVY8_1X16, 8 },
{ MEDIA_BUS_FMT_VYUY8_1X16, 8 },
{ MEDIA_BUS_FMT_YUYV8_1X16, 8 },
@@ -98,6 +93,21 @@ static const struct csiphy_format csiphy_formats_sdm845[] = {
{ MEDIA_BUS_FMT_Y10_1X10, 10 },
};
+const struct csiphy_formats csiphy_formats_8x16 = {
+ .nformats = ARRAY_SIZE(formats_8x16),
+ .formats = formats_8x16
+};
+
+const struct csiphy_formats csiphy_formats_8x96 = {
+ .nformats = ARRAY_SIZE(formats_8x96),
+ .formats = formats_8x96
+};
+
+const struct csiphy_formats csiphy_formats_sdm845 = {
+ .nformats = ARRAY_SIZE(formats_sdm845),
+ .formats = formats_sdm845
+};
+
/*
* csiphy_get_bpp - map media bus format to bits per pixel
* @formats: supported media bus formats array
@@ -106,7 +116,7 @@ static const struct csiphy_format csiphy_formats_sdm845[] = {
*
* Return number of bits per pixel
*/
-static u8 csiphy_get_bpp(const struct csiphy_format *formats,
+static u8 csiphy_get_bpp(const struct csiphy_format_info *formats,
unsigned int nformats, u32 code)
{
unsigned int i;
@@ -131,7 +141,7 @@ static int csiphy_set_clock_rates(struct csiphy_device *csiphy)
int i, j;
int ret;
- u8 bpp = csiphy_get_bpp(csiphy->formats, csiphy->nformats,
+ u8 bpp = csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->formats->nformats,
csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
@@ -244,7 +254,7 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
struct csiphy_config *cfg = &csiphy->cfg;
s64 link_freq;
u8 lane_mask = csiphy->res->hw_ops->get_lane_mask(&cfg->csi2->lane_cfg);
- u8 bpp = csiphy_get_bpp(csiphy->formats, csiphy->nformats,
+ u8 bpp = csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->formats->nformats,
csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
u8 val;
@@ -350,12 +360,12 @@ static void csiphy_try_format(struct csiphy_device *csiphy,
case MSM_CSIPHY_PAD_SINK:
/* Set format on sink pad */
- for (i = 0; i < csiphy->nformats; i++)
- if (fmt->code == csiphy->formats[i].code)
+ for (i = 0; i < csiphy->res->formats->nformats; i++)
+ if (fmt->code == csiphy->res->formats->formats[i].code)
break;
/* If not found, use UYVY as default */
- if (i >= csiphy->nformats)
+ if (i >= csiphy->res->formats->nformats)
fmt->code = MEDIA_BUS_FMT_UYVY8_1X16;
fmt->width = clamp_t(u32, fmt->width, 1, 8191);
@@ -392,10 +402,10 @@ static int csiphy_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *format;
if (code->pad == MSM_CSIPHY_PAD_SINK) {
- if (code->index >= csiphy->nformats)
+ if (code->index >= csiphy->res->formats->nformats)
return -EINVAL;
- code->code = csiphy->formats[code->index].code;
+ code->code = csiphy->res->formats->formats[code->index].code;
} else {
if (code->index > 0)
return -EINVAL;
@@ -566,24 +576,6 @@ int msm_csiphy_subdev_init(struct camss *camss,
csiphy->cfg.combo_mode = 0;
csiphy->res = &res->csiphy;
- switch (camss->res->version) {
- case CAMSS_8x16:
- csiphy->formats = csiphy_formats_8x16;
- csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x16);
- break;
- case CAMSS_8x96:
- case CAMSS_660:
- csiphy->formats = csiphy_formats_8x96;
- csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x96);
- break;
- case CAMSS_845:
- case CAMSS_8250:
- case CAMSS_8280XP:
- csiphy->formats = csiphy_formats_sdm845;
- csiphy->nformats = ARRAY_SIZE(csiphy_formats_sdm845);
- break;
- }
-
/* Memory */
csiphy->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]);
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/media/platform/qcom/camss/camss-csiphy.h
index 7bd68129ca49..47f0b6b09eba 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.h
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.h
@@ -42,6 +42,16 @@ struct csiphy_config {
struct csiphy_csi2_cfg *csi2;
};
+struct csiphy_format_info {
+ u32 code;
+ u8 bpp;
+};
+
+struct csiphy_formats {
+ unsigned int nformats;
+ const struct csiphy_format_info *formats;
+};
+
struct csiphy_device;
struct csiphy_hw_ops {
@@ -65,6 +75,7 @@ struct csiphy_hw_ops {
struct csiphy_subdev_resources {
const struct csiphy_hw_ops *hw_ops;
+ const struct csiphy_formats *formats;
};
struct csiphy_device {
@@ -83,8 +94,6 @@ struct csiphy_device {
struct csiphy_config cfg;
struct v4l2_mbus_framefmt fmt[MSM_CSIPHY_PADS_NUM];
const struct csiphy_subdev_resources *res;
- const struct csiphy_format *formats;
- unsigned int nformats;
};
struct camss_subdev_resources;
@@ -98,6 +107,10 @@ int msm_csiphy_register_entity(struct csiphy_device *csiphy,
void msm_csiphy_unregister_entity(struct csiphy_device *csiphy);
+extern const struct csiphy_formats csiphy_formats_8x16;
+extern const struct csiphy_formats csiphy_formats_8x96;
+extern const struct csiphy_formats csiphy_formats_sdm845;
+
extern const struct csiphy_hw_ops csiphy_ops_2ph_1_0;
extern const struct csiphy_hw_ops csiphy_ops_3ph_1_0;
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index efce883d4121..d57bbea32107 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -45,7 +45,8 @@ static const struct camss_subdev_resources csiphy_res_8x16[] = {
.interrupt = { "csiphy0" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_2ph_1_0
+ .hw_ops = &csiphy_ops_2ph_1_0,
+ .formats = &csiphy_formats_8x16
}
},
@@ -61,7 +62,8 @@ static const struct camss_subdev_resources csiphy_res_8x16[] = {
.interrupt = { "csiphy1" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_2ph_1_0
+ .hw_ops = &csiphy_ops_2ph_1_0,
+ .formats = &csiphy_formats_8x16
}
}
};
@@ -165,7 +167,8 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
.interrupt = { "csiphy0" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_8x96
}
},
@@ -181,7 +184,8 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
.interrupt = { "csiphy1" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_8x96
}
},
@@ -197,7 +201,8 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
.interrupt = { "csiphy2" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_8x96
}
}
};
@@ -374,7 +379,8 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
.interrupt = { "csiphy0" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_8x96
}
},
@@ -392,7 +398,8 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
.interrupt = { "csiphy1" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_8x96
}
},
@@ -410,7 +417,8 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
.interrupt = { "csiphy2" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_8x96
}
}
};
@@ -609,7 +617,8 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
.interrupt = { "csiphy0" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
@@ -631,7 +640,8 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
.interrupt = { "csiphy1" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
@@ -653,7 +663,8 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
.interrupt = { "csiphy2" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
@@ -675,7 +686,8 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
.interrupt = { "csiphy3" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
}
};
@@ -854,7 +866,8 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
.interrupt = { "csiphy0" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
/* CSIPHY1 */
@@ -867,7 +880,8 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
.interrupt = { "csiphy1" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
/* CSIPHY2 */
@@ -880,7 +894,8 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
.interrupt = { "csiphy2" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
/* CSIPHY3 */
@@ -893,7 +908,8 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
.interrupt = { "csiphy3" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
/* CSIPHY4 */
@@ -906,7 +922,8 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
.interrupt = { "csiphy4" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
/* CSIPHY5 */
@@ -919,7 +936,8 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
.interrupt = { "csiphy5" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
}
};
@@ -1136,7 +1154,8 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
.interrupt = { "csiphy0" },
.type = CAMSS_SUBDEV_TYPE_CSIPHY,
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
/* CSIPHY1 */
@@ -1148,7 +1167,8 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
.reg = { "csiphy1" },
.interrupt = { "csiphy1" },
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
/* CSIPHY2 */
@@ -1160,7 +1180,8 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
.reg = { "csiphy2" },
.interrupt = { "csiphy2" },
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
/* CSIPHY3 */
@@ -1172,7 +1193,8 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
.reg = { "csiphy3" },
.interrupt = { "csiphy3" },
.csiphy = {
- .hw_ops = &csiphy_ops_3ph_1_0
+ .hw_ops = &csiphy_ops_3ph_1_0,
+ .formats = &csiphy_formats_sdm845
}
},
};
--
2.17.1
On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
> From: Radoslav Tsvetkov <[email protected]>
>
> Currently resources structure grows with additional parameters required for
> each sub-deivce. However each sub-device has some specific resources or
> configurations which need to be passed during the initialization.
>
> This change adds per sub-device type structure to simplify the things
> and removes the magical void pointer to hw_ops.
>
> Signed-off-by: Radoslav Tsvetkov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
Reviewed-by: Bryan O'Donoghue <[email protected]>
Tested-by: Bryan O'Donoghue <[email protected]> #
sc8280xp/sm8250/sdm845/apq8016
On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
> From: Radoslav Tsvetkov <[email protected]>
>
> Video node formats have direct dependency by the sub-device pad formats.
> Remove dependency for SoC version and move format definitions in device
> which creates video node.
>
> This commit attaches a struct to the VFE resources that holds format
> description, so it is much easier to assign them to the video node.
> No need to use a switch-case.
>
> NOTE: The mbus_bpp is used to calculate the clock rates and is different
> from bpp which is the bits per pixel written to memory. We need to keep
> both values to not break the calcualtions.
>
> Signed-off-by: Radoslav Tsvetkov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
Reviewed-by: Bryan O'Donoghue <[email protected]>
Tested-by: Bryan O'Donoghue <[email protected]> #
sc8280xp/sm8250/sdm845/apq8016
On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
> From: Radoslav Tsvetkov <[email protected]>
>
> Following the example of VFE, move all formats of the decoder
> to camss-csid.c and attach them to the subdevices resources.
>
> Signed-off-by: Radoslav Tsvetkov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
> .../platform/qcom/camss/camss-csid-4-1.c | 132 +----
> .../platform/qcom/camss/camss-csid-4-7.c | 160 +-----
> .../platform/qcom/camss/camss-csid-gen2.c | 164 +-----
> .../media/platform/qcom/camss/camss-csid.c | 474 +++++++++++++++++-
> .../media/platform/qcom/camss/camss-csid.h | 24 +-
> drivers/media/platform/qcom/camss/camss.c | 75 ++-
> 6 files changed, 538 insertions(+), 491 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-csid-4-1.c b/drivers/media/platform/qcom/camss/camss-csid-4-1.c
> index dd49a40e6a70..c95861420502 100644
> --- a/drivers/media/platform/qcom/camss/camss-csid-4-1.c
> +++ b/drivers/media/platform/qcom/camss/camss-csid-4-1.c
Reviewed-by: Bryan O'Donoghue <[email protected]>
Tested-by: Bryan O'Donoghue <[email protected]> #
sc8280xp/sm8250/sdm845/apq8016
On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
> From: Radoslav Tsvetkov <[email protected]>
>
> Move out the format related helper functions from vfe and video in a
> separate file. The goal here is to create a format API.
>
> Signed-off-by: Radoslav Tsvetkov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
Reviewed-by: Bryan O'Donoghue <[email protected]>
Tested-by: Bryan O'Donoghue <[email protected]> #
sc8280xp/sm8250/sdm845/apq8016
On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
> From: Milen Mitkov <[email protected]>
>
> Split the RAW interface (RDI), the CSID receiver (RX)
> and test pattern generator (testgen), configurations
> for CSID on Titan 170
>
> Signed-off-by: Milen Mitkov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
Reviewed-by: Bryan O'Donoghue <[email protected]>
Tested-by: Bryan O'Donoghue <[email protected]> #
sc8280xp/sm8250/sdm845/apq8016
On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
> From: Atanas Filipov <[email protected]>
>
> Split link and register operations.
> Add dedicated link callback according to SoC identifier.
>
> Signed-off-by: Atanas Filipov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
Reviewed-by: Bryan O'Donoghue <[email protected]>
Tested-by: Bryan O'Donoghue <[email protected]> #
sc8280xp/sm8250/sdm845/apq8016
On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
> From: Milen Mitkov <[email protected]>
>
> Decouple the direct calls to VFE's vfe_get/put in the CSID subdev
> in order to prepare for the introduction of IFE subdev.
>
> Also decouple CSID base address from VFE since on the Titan platform
> CSID register base address resides within VFE's base address.
>
> Signed-off-by: Milen Mitkov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
Reviewed-by: Bryan O'Donoghue <[email protected]>
Tested-by: Bryan O'Donoghue <[email protected]> #
sc8280xp/sm8250/sdm845/apq8016
On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
> From: Radoslav Tsvetkov <[email protected]>
>
> Following the example of VFE and CSID, attach the CSIPHY
> formats to the subdevices resources.
>
> Signed-off-by: Radoslav Tsvetkov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
Reviewed-by: Bryan O'Donoghue <[email protected]>
Tested-by: Bryan O'Donoghue <[email protected]> #
sc8280xp/sm8250/sdm845/apq8016
On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
> Changes in V3:
> - Incorporate missing changes in resources reported and fixed by
> Bryan O'Donoghue <[email protected]> taken from the branch:
> https://git.codelinaro.org/bryan.odonoghue/kernel/-/tree/sc8280xp-6.9-rc1-camss-resource-change-verification?ref_type=heads
> - Added missing signed-off to the changes submitted by me.
Took a little while to verify this series on the four reference
platforms on a reasonable base of -next or -stable.
Here's the reference branch:
https://git.codelinaro.org/bryan.odonoghue/kernel/-/tree/linux-stable-24-05-10--x13s-mmsol-integration-in-test-imx577-fix-rb3-gen1-debug?ref_type=heads
@Hans I'd be grateful if you can pull Gjorgji's series in at your
earliest convenience.
---
bod
On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
> + .type = CAMSS_SUBDEV_TYPE_CSIPHY,
As Matti pointed out to me on IRC, the .type value here isn't populated
in the rest of the 8280xp resources.
I completely missed that but, then again this appears to be a dead field
in this series so it makes no difference if it is populated.
I realise it is probably of use in code you _haven't_ yet published but,
for now I think we should drop this field, since its dead code.
I'll send a fixup patch for this, I don't think there's a need for you
to send the whole series again.
---
bod
From: Radoslav Tsvetkov <[email protected]>
Currently resources structure grows with additional parameters required for
each sub-deivce. However each sub-device has some specific resources or
configurations which need to be passed during the initialization.
This change adds per sub-device type structure to simplify the things
and removes the magical void pointer to hw_ops.
Signed-off-by: Radoslav Tsvetkov <[email protected]>
Signed-off-by: Gjorgji Rosikopulos <[email protected]>
Signed-off-by: Bryan O'Donoghue <[email protected]>
---
.../media/platform/qcom/camss/camss-csid.c | 22 +-
.../media/platform/qcom/camss/camss-csid.h | 7 +-
.../media/platform/qcom/camss/camss-csiphy.c | 14 +-
.../media/platform/qcom/camss/camss-csiphy.h | 6 +-
.../media/platform/qcom/camss/camss-vfe-17x.c | 10 +-
.../media/platform/qcom/camss/camss-vfe-4-1.c | 4 +-
.../media/platform/qcom/camss/camss-vfe-4-7.c | 6 +-
.../media/platform/qcom/camss/camss-vfe-4-8.c | 6 +-
.../platform/qcom/camss/camss-vfe-gen1.c | 8 +-
drivers/media/platform/qcom/camss/camss-vfe.c | 54 ++-
drivers/media/platform/qcom/camss/camss-vfe.h | 11 +-
drivers/media/platform/qcom/camss/camss.c | 381 ++++++++++++------
drivers/media/platform/qcom/camss/camss.h | 10 +-
13 files changed, 343 insertions(+), 196 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index eb27d69e89a16..d1a22e07fdb6c 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -202,7 +202,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
enable_irq(csid->irq);
- ret = csid->ops->reset(csid);
+ ret = csid->res->hw_ops->reset(csid);
if (ret < 0) {
disable_irq(csid->irq);
camss_disable_clocks(csid->nclocks, csid->clock);
@@ -212,7 +212,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
return ret;
}
- csid->ops->hw_version(csid);
+ csid->res->hw_ops->hw_version(csid);
} else {
disable_irq(csid->irq);
camss_disable_clocks(csid->nclocks, csid->clock);
@@ -253,7 +253,7 @@ static int csid_set_stream(struct v4l2_subdev *sd, int enable)
}
if (csid->phy.need_vc_update) {
- csid->ops->configure_stream(csid, enable);
+ csid->res->hw_ops->configure_stream(csid, enable);
csid->phy.need_vc_update = false;
}
@@ -325,7 +325,7 @@ static void csid_try_format(struct csid_device *csid,
*fmt = *__csid_get_format(csid, sd_state,
MSM_CSID_PAD_SINK, which);
- fmt->code = csid->ops->src_pad_code(csid, fmt->code, 0, code);
+ fmt->code = csid->res->hw_ops->src_pad_code(csid, fmt->code, 0, code);
} else {
/* Test generator is enabled, set format on source */
/* pad to allow test generator usage */
@@ -375,8 +375,8 @@ static int csid_enum_mbus_code(struct v4l2_subdev *sd,
MSM_CSID_PAD_SINK,
code->which);
- code->code = csid->ops->src_pad_code(csid, sink_fmt->code,
- code->index, 0);
+ code->code = csid->res->hw_ops->src_pad_code(csid, sink_fmt->code,
+ code->index, 0);
if (!code->code)
return -EINVAL;
} else {
@@ -529,7 +529,7 @@ static int csid_set_test_pattern(struct csid_device *csid, s32 value)
tg->enabled = !!value;
- return csid->ops->configure_testgen_pattern(csid, value);
+ return csid->res->hw_ops->configure_testgen_pattern(csid, value);
}
/*
@@ -575,9 +575,9 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
csid->camss = camss;
csid->id = id;
- csid->ops = res->ops;
+ csid->res = &res->csid;
- csid->ops->subdev_init(csid);
+ csid->res->hw_ops->subdev_init(csid);
/* Memory */
@@ -605,7 +605,7 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
csid->irq = ret;
snprintf(csid->irq_name, sizeof(csid->irq_name), "%s_%s%d",
dev_name(dev), MSM_CSID_NAME, csid->id);
- ret = devm_request_irq(dev, csid->irq, csid->ops->isr,
+ ret = devm_request_irq(dev, csid->irq, csid->res->hw_ops->isr,
IRQF_TRIGGER_RISING | IRQF_NO_AUTOEN,
csid->irq_name, csid);
if (ret < 0) {
@@ -899,5 +899,5 @@ void msm_csid_unregister_entity(struct csid_device *csid)
inline bool csid_is_lite(struct csid_device *csid)
{
- return csid->camss->res->csid_res[csid->id].is_lite;
+ return csid->camss->res->csid_res[csid->id].csid.is_lite;
}
diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media/platform/qcom/camss/camss-csid.h
index fddccb69da13a..8d2971aa9ef8b 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.h
+++ b/drivers/media/platform/qcom/camss/camss-csid.h
@@ -149,6 +149,11 @@ struct csid_hw_ops {
void (*subdev_init)(struct csid_device *csid);
};
+struct csid_subdev_resources {
+ bool is_lite;
+ const struct csid_hw_ops *hw_ops;
+};
+
struct csid_device {
struct camss *camss;
u8 id;
@@ -169,7 +174,7 @@ struct csid_device {
struct v4l2_ctrl *testgen_mode;
const struct csid_format *formats;
unsigned int nformats;
- const struct csid_hw_ops *ops;
+ const struct csid_subdev_resources *res;
};
struct camss_subdev_resources;
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
index 45b3a8e5dea49..f26ddf1af9d42 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
@@ -216,9 +216,9 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int on)
enable_irq(csiphy->irq);
- csiphy->ops->reset(csiphy);
+ csiphy->res->hw_ops->reset(csiphy);
- csiphy->ops->hw_version_read(csiphy, dev);
+ csiphy->res->hw_ops->hw_version_read(csiphy, dev);
} else {
disable_irq(csiphy->irq);
@@ -243,7 +243,7 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
{
struct csiphy_config *cfg = &csiphy->cfg;
s64 link_freq;
- u8 lane_mask = csiphy->ops->get_lane_mask(&cfg->csi2->lane_cfg);
+ u8 lane_mask = csiphy->res->hw_ops->get_lane_mask(&cfg->csi2->lane_cfg);
u8 bpp = csiphy_get_bpp(csiphy->formats, csiphy->nformats,
csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
@@ -272,7 +272,7 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
wmb();
}
- csiphy->ops->lanes_enable(csiphy, cfg, link_freq, lane_mask);
+ csiphy->res->hw_ops->lanes_enable(csiphy, cfg, link_freq, lane_mask);
return 0;
}
@@ -285,7 +285,7 @@ static int csiphy_stream_on(struct csiphy_device *csiphy)
*/
static void csiphy_stream_off(struct csiphy_device *csiphy)
{
- csiphy->ops->lanes_disable(csiphy, &csiphy->cfg);
+ csiphy->res->hw_ops->lanes_disable(csiphy, &csiphy->cfg);
}
@@ -564,7 +564,7 @@ int msm_csiphy_subdev_init(struct camss *camss,
csiphy->camss = camss;
csiphy->id = id;
csiphy->cfg.combo_mode = 0;
- csiphy->ops = res->ops;
+ csiphy->res = &res->csiphy;
switch (camss->res->version) {
case CAMSS_8x16:
@@ -610,7 +610,7 @@ int msm_csiphy_subdev_init(struct camss *camss,
snprintf(csiphy->irq_name, sizeof(csiphy->irq_name), "%s_%s%d",
dev_name(dev), MSM_CSIPHY_NAME, csiphy->id);
- ret = devm_request_irq(dev, csiphy->irq, csiphy->ops->isr,
+ ret = devm_request_irq(dev, csiphy->irq, csiphy->res->hw_ops->isr,
IRQF_TRIGGER_RISING | IRQF_NO_AUTOEN,
csiphy->irq_name, csiphy);
if (ret < 0) {
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.h b/drivers/media/platform/qcom/camss/camss-csiphy.h
index c9b7fe82b1f0d..7bd68129ca498 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.h
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.h
@@ -63,6 +63,10 @@ struct csiphy_hw_ops {
irqreturn_t (*isr)(int irq, void *dev);
};
+struct csiphy_subdev_resources {
+ const struct csiphy_hw_ops *hw_ops;
+};
+
struct csiphy_device {
struct camss *camss;
u8 id;
@@ -78,7 +82,7 @@ struct csiphy_device {
u32 timer_clk_rate;
struct csiphy_config cfg;
struct v4l2_mbus_framefmt fmt[MSM_CSIPHY_PADS_NUM];
- const struct csiphy_hw_ops *ops;
+ const struct csiphy_subdev_resources *res;
const struct csiphy_format *formats;
unsigned int nformats;
};
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
index 795ac3815339a..380c99321030e 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
@@ -353,7 +353,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
writel_relaxed(status0, vfe->base + VFE_IRQ_CLEAR_0);
writel_relaxed(status1, vfe->base + VFE_IRQ_CLEAR_1);
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) {
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
vfe_bus_status[i] = readl_relaxed(vfe->base + VFE_BUS_IRQ_STATUS(i));
writel_relaxed(vfe_bus_status[i], vfe->base + VFE_BUS_IRQ_CLEAR(i));
}
@@ -367,11 +367,11 @@ static irqreturn_t vfe_isr(int irq, void *dev)
if (status0 & STATUS_0_RESET_ACK)
vfe->isr_ops.reset_ack(vfe);
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++)
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++)
if (status0 & STATUS_0_RDI_REG_UPDATE(i))
vfe->isr_ops.reg_update(vfe, i);
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++)
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++)
if (status0 & STATUS_1_RDI_SOF(i))
vfe->isr_ops.sof(vfe, i);
@@ -442,7 +442,7 @@ static int vfe_enable_output(struct vfe_line *line)
{
struct vfe_device *vfe = to_vfe(line);
struct vfe_output *output = &line->output;
- const struct vfe_hw_ops *ops = vfe->ops;
+ const struct vfe_hw_ops *ops = vfe->res->hw_ops;
struct media_entity *sensor;
unsigned long flags;
unsigned int frame_skip = 0;
@@ -560,7 +560,7 @@ static void vfe_isr_reg_update(struct vfe_device *vfe, enum vfe_line_id line_id)
unsigned long flags;
spin_lock_irqsave(&vfe->output_lock, flags);
- vfe->ops->reg_update_clear(vfe, line_id);
+ vfe->res->hw_ops->reg_update_clear(vfe, line_id);
output = &vfe->line[line_id].output;
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c
index ef6b34c915df1..1bd3a6ef1d04d 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-4-1.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-4-1.c
@@ -892,7 +892,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
u32 value0, value1;
int i, j;
- vfe->ops->isr_read(vfe, &value0, &value1);
+ vfe->res->hw_ops->isr_read(vfe, &value0, &value1);
dev_dbg(vfe->camss->dev, "VFE: status0 = 0x%08x, status1 = 0x%08x\n",
value0, value1);
@@ -901,7 +901,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
vfe->isr_ops.reset_ack(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_VIOLATION)
- vfe->ops->violation_read(vfe);
+ vfe->res->hw_ops->violation_read(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_BUS_BDG_HALT_ACK)
vfe->isr_ops.halt_ack(vfe);
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c
index 7655d22a9fda2..ce0719106bd34 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-4-7.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-4-7.c
@@ -1050,7 +1050,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
u32 value0, value1;
int i, j;
- vfe->ops->isr_read(vfe, &value0, &value1);
+ vfe->res->hw_ops->isr_read(vfe, &value0, &value1);
dev_dbg(vfe->camss->dev, "VFE: status0 = 0x%08x, status1 = 0x%08x\n",
value0, value1);
@@ -1059,12 +1059,12 @@ static irqreturn_t vfe_isr(int irq, void *dev)
vfe->isr_ops.reset_ack(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_VIOLATION)
- vfe->ops->violation_read(vfe);
+ vfe->res->hw_ops->violation_read(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_BUS_BDG_HALT_ACK)
vfe->isr_ops.halt_ack(vfe);
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++)
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++)
if (value0 & VFE_0_IRQ_STATUS_0_line_n_REG_UPDATE(i))
vfe->isr_ops.reg_update(vfe, i);
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c
index f52fa30f3853e..6b59c8107a3c7 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-4-8.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-4-8.c
@@ -980,7 +980,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
u32 value0, value1;
int i, j;
- vfe->ops->isr_read(vfe, &value0, &value1);
+ vfe->res->hw_ops->isr_read(vfe, &value0, &value1);
dev_dbg(vfe->camss->dev, "VFE: status0 = 0x%08x, status1 = 0x%08x\n",
value0, value1);
@@ -989,12 +989,12 @@ static irqreturn_t vfe_isr(int irq, void *dev)
vfe->isr_ops.reset_ack(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_VIOLATION)
- vfe->ops->violation_read(vfe);
+ vfe->res->hw_ops->violation_read(vfe);
if (value1 & VFE_0_IRQ_STATUS_1_BUS_BDG_HALT_ACK)
vfe->isr_ops.halt_ack(vfe);
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++)
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++)
if (value0 & VFE_0_IRQ_STATUS_0_line_n_REG_UPDATE(i))
vfe->isr_ops.reg_update(vfe, i);
diff --git a/drivers/media/platform/qcom/camss/camss-vfe-gen1.c b/drivers/media/platform/qcom/camss/camss-vfe-gen1.c
index 239d3d4ac6661..eb33c03df27e5 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-gen1.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-gen1.c
@@ -37,7 +37,7 @@ static int vfe_disable_output(struct vfe_line *line)
{
struct vfe_device *vfe = to_vfe(line);
struct vfe_output *output = &line->output;
- const struct vfe_hw_ops *ops = vfe->ops;
+ const struct vfe_hw_ops *ops = vfe->res->hw_ops;
unsigned long flags;
unsigned long time;
unsigned int i;
@@ -162,14 +162,14 @@ static void vfe_output_frame_drop(struct vfe_device *vfe,
vfe->ops_gen1->wm_set_framedrop_pattern(vfe, output->wm_idx[i], drop_pattern);
}
- vfe->ops->reg_update(vfe, container_of(output, struct vfe_line, output)->id);
+ vfe->res->hw_ops->reg_update(vfe, container_of(output, struct vfe_line, output)->id);
}
static int vfe_enable_output(struct vfe_line *line)
{
struct vfe_device *vfe = to_vfe(line);
struct vfe_output *output = &line->output;
- const struct vfe_hw_ops *ops = vfe->ops;
+ const struct vfe_hw_ops *ops = vfe->res->hw_ops;
struct media_entity *sensor;
unsigned long flags;
unsigned int frame_skip = 0;
@@ -545,7 +545,7 @@ static void vfe_isr_reg_update(struct vfe_device *vfe, enum vfe_line_id line_id)
unsigned long flags;
spin_lock_irqsave(&vfe->output_lock, flags);
- vfe->ops->reg_update_clear(vfe, line_id);
+ vfe->res->hw_ops->reg_update_clear(vfe, line_id);
output = &line->output;
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index d875237cf2443..459c70a4b3199 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -296,7 +296,7 @@ int vfe_reset(struct vfe_device *vfe)
reinit_completion(&vfe->reset_complete);
- vfe->ops->global_reset(vfe);
+ vfe->res->hw_ops->global_reset(vfe);
time = wait_for_completion_timeout(&vfe->reset_complete,
msecs_to_jiffies(VFE_RESET_TIMEOUT_MS));
@@ -312,7 +312,7 @@ static void vfe_init_outputs(struct vfe_device *vfe)
{
int i;
- for (i = 0; i < vfe->line_num; i++) {
+ for (i = 0; i < vfe->res->line_num; i++) {
struct vfe_output *output = &vfe->line[i].output;
output->state = VFE_OUTPUT_OFF;
@@ -421,7 +421,7 @@ static int vfe_disable_output(struct vfe_line *line)
spin_lock_irqsave(&vfe->output_lock, flags);
for (i = 0; i < output->wm_num; i++)
- vfe->ops->vfe_wm_stop(vfe, output->wm_idx[i]);
+ vfe->res->hw_ops->vfe_wm_stop(vfe, output->wm_idx[i]);
output->gen2.active_num = 0;
spin_unlock_irqrestore(&vfe->output_lock, flags);
@@ -537,7 +537,7 @@ static int vfe_set_clock_rates(struct vfe_device *vfe)
int i, j;
int ret;
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) {
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
ret = camss_get_pixel_clock(&vfe->line[i].subdev.entity,
&pixel_clock[i]);
if (ret)
@@ -551,7 +551,7 @@ static int vfe_set_clock_rates(struct vfe_device *vfe)
u64 min_rate = 0;
long rate;
- for (j = VFE_LINE_RDI0; j < vfe->line_num; j++) {
+ for (j = VFE_LINE_RDI0; j < vfe->res->line_num; j++) {
u32 tmp;
u8 bpp;
@@ -618,7 +618,7 @@ static int vfe_check_clock_rates(struct vfe_device *vfe)
int i, j;
int ret;
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) {
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
ret = camss_get_pixel_clock(&vfe->line[i].subdev.entity,
&pixel_clock[i]);
if (ret)
@@ -632,7 +632,7 @@ static int vfe_check_clock_rates(struct vfe_device *vfe)
u64 min_rate = 0;
unsigned long rate;
- for (j = VFE_LINE_RDI0; j < vfe->line_num; j++) {
+ for (j = VFE_LINE_RDI0; j < vfe->res->line_num; j++) {
u32 tmp;
u8 bpp;
@@ -675,7 +675,7 @@ int vfe_get(struct vfe_device *vfe)
mutex_lock(&vfe->power_lock);
if (vfe->power_count == 0) {
- ret = vfe->ops->pm_domain_on(vfe);
+ ret = vfe->res->hw_ops->pm_domain_on(vfe);
if (ret < 0)
goto error_pm_domain;
@@ -700,7 +700,7 @@ int vfe_get(struct vfe_device *vfe)
vfe_init_outputs(vfe);
- vfe->ops->hw_version(vfe);
+ vfe->res->hw_ops->hw_version(vfe);
} else {
ret = vfe_check_clock_rates(vfe);
if (ret < 0)
@@ -718,7 +718,7 @@ int vfe_get(struct vfe_device *vfe)
error_pm_runtime_get:
pm_runtime_put_sync(vfe->camss->dev);
error_domain_off:
- vfe->ops->pm_domain_off(vfe);
+ vfe->res->hw_ops->pm_domain_off(vfe);
error_pm_domain:
mutex_unlock(&vfe->power_lock);
@@ -740,11 +740,11 @@ void vfe_put(struct vfe_device *vfe)
} else if (vfe->power_count == 1) {
if (vfe->was_streaming) {
vfe->was_streaming = 0;
- vfe->ops->vfe_halt(vfe);
+ vfe->res->hw_ops->vfe_halt(vfe);
}
camss_disable_clocks(vfe->nclocks, vfe->clock);
pm_runtime_put_sync(vfe->camss->dev);
- vfe->ops->pm_domain_off(vfe);
+ vfe->res->hw_ops->pm_domain_off(vfe);
}
vfe->power_count--;
@@ -834,12 +834,12 @@ static int vfe_set_stream(struct v4l2_subdev *sd, int enable)
if (enable) {
line->output.state = VFE_OUTPUT_RESERVED;
- ret = vfe->ops->vfe_enable(line);
+ ret = vfe->res->hw_ops->vfe_enable(line);
if (ret < 0)
dev_err(vfe->camss->dev,
"Failed to enable vfe outputs\n");
} else {
- ret = vfe->ops->vfe_disable(line);
+ ret = vfe->res->hw_ops->vfe_disable(line);
if (ret < 0)
dev_err(vfe->camss->dev,
"Failed to disable vfe outputs\n");
@@ -1376,23 +1376,24 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
int i, j;
int ret;
- vfe->ops = res->ops;
-
- if (!res->line_num)
+ if (!res->vfe.line_num)
return -EINVAL;
+ vfe->res = &res->vfe;
+ vfe->res->hw_ops->subdev_init(dev, vfe);
+
/* Power domain */
- if (res->pd_name) {
+ if (res->vfe.pd_name) {
vfe->genpd = dev_pm_domain_attach_by_name(camss->dev,
- res->pd_name);
+ res->vfe.pd_name);
if (IS_ERR(vfe->genpd)) {
ret = PTR_ERR(vfe->genpd);
return ret;
}
}
- if (!vfe->genpd && res->has_pd) {
+ if (!vfe->genpd && res->vfe.has_pd) {
/*
* Legacy magic index.
* Requires
@@ -1409,9 +1410,6 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
return PTR_ERR(vfe->genpd);
}
- vfe->line_num = res->line_num;
- vfe->ops->subdev_init(dev, vfe);
-
/* Memory */
vfe->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]);
@@ -1429,7 +1427,7 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
vfe->irq = ret;
snprintf(vfe->irq_name, sizeof(vfe->irq_name), "%s_%s%d",
dev_name(dev), MSM_VFE_NAME, id);
- ret = devm_request_irq(dev, vfe->irq, vfe->ops->isr,
+ ret = devm_request_irq(dev, vfe->irq, vfe->res->hw_ops->isr,
IRQF_TRIGGER_RISING, vfe->irq_name, vfe);
if (ret < 0) {
dev_err(dev, "request_irq failed: %d\n", ret);
@@ -1488,7 +1486,7 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
vfe->id = id;
vfe->reg_update = 0;
- for (i = VFE_LINE_RDI0; i < vfe->line_num; i++) {
+ for (i = VFE_LINE_RDI0; i < vfe->res->line_num; i++) {
struct vfe_line *l = &vfe->line[i];
l->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
@@ -1636,7 +1634,7 @@ int msm_vfe_register_entities(struct vfe_device *vfe,
int ret;
int i;
- for (i = 0; i < vfe->line_num; i++) {
+ for (i = 0; i < vfe->res->line_num; i++) {
char name[32];
sd = &vfe->line[i].subdev;
@@ -1743,7 +1741,7 @@ void msm_vfe_unregister_entities(struct vfe_device *vfe)
mutex_destroy(&vfe->power_lock);
mutex_destroy(&vfe->stream_lock);
- for (i = 0; i < vfe->line_num; i++) {
+ for (i = 0; i < vfe->res->line_num; i++) {
struct v4l2_subdev *sd = &vfe->line[i].subdev;
struct camss_video *video_out = &vfe->line[i].video_out;
@@ -1755,5 +1753,5 @@ void msm_vfe_unregister_entities(struct vfe_device *vfe)
bool vfe_is_lite(struct vfe_device *vfe)
{
- return vfe->camss->res->vfe_res[vfe->id].is_lite;
+ return vfe->camss->res->vfe_res[vfe->id].vfe.is_lite;
}
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h
index 0572c9b08e112..87fc159c48cc5 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.h
+++ b/drivers/media/platform/qcom/camss/camss-vfe.h
@@ -126,6 +126,14 @@ struct vfe_isr_ops {
void (*wm_done)(struct vfe_device *vfe, u8 wm);
};
+struct vfe_subdev_resources {
+ bool is_lite;
+ u8 line_num;
+ bool has_pd;
+ char *pd_name;
+ const struct vfe_hw_ops *hw_ops;
+};
+
struct vfe_device {
struct camss *camss;
u8 id;
@@ -143,10 +151,9 @@ struct vfe_device {
spinlock_t output_lock;
enum vfe_line_id wm_output_map[MSM_VFE_IMAGE_MASTERS_NUM];
struct vfe_line line[VFE_LINE_NUM_MAX];
- u8 line_num;
u32 reg_update;
u8 was_streaming;
- const struct vfe_hw_ops *ops;
+ const struct vfe_subdev_resources *res;
const struct vfe_hw_ops_gen1 *ops_gen1;
struct vfe_isr_ops isr_ops;
struct camss_video_ops video_ops;
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index 1923615f0eea7..34bac001073c0 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -43,7 +43,9 @@ static const struct camss_subdev_resources csiphy_res_8x16[] = {
{ 100000000, 200000000 } },
.reg = { "csiphy0", "csiphy0_clk_mux" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_2ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_2ph_1_0
+ }
},
/* CSIPHY1 */
@@ -56,7 +58,9 @@ static const struct camss_subdev_resources csiphy_res_8x16[] = {
{ 100000000, 200000000 } },
.reg = { "csiphy1", "csiphy1_clk_mux" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_2ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_2ph_1_0
+ }
}
};
@@ -76,7 +80,9 @@ static const struct camss_subdev_resources csid_res_8x16[] = {
{ 0 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_4_1,
+ .csid = {
+ .hw_ops = &csid_ops_4_1
+ }
},
/* CSID1 */
@@ -94,7 +100,9 @@ static const struct camss_subdev_resources csid_res_8x16[] = {
{ 0 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_4_1,
+ .csid = {
+ .hw_ops = &csid_ops_4_1
+ }
},
};
@@ -105,8 +113,7 @@ static const struct camss_subdev_resources ispif_res_8x16 = {
"csi1", "csi1_pix", "csi1_rdi" },
.clock_for_reset = { "vfe0", "csi_vfe0" },
.reg = { "ispif", "csi_clk_mux" },
- .interrupt = { "ispif" }
-
+ .interrupt = { "ispif" },
};
static const struct camss_subdev_resources vfe_res_8x16[] = {
@@ -128,8 +135,10 @@ static const struct camss_subdev_resources vfe_res_8x16[] = {
{ 0 } },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .line_num = 3,
- .ops = &vfe_ops_4_1
+ .vfe = {
+ .line_num = 3,
+ .hw_ops = &vfe_ops_4_1
+ }
}
};
@@ -144,7 +153,9 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
{ 100000000, 200000000, 266666667 } },
.reg = { "csiphy0", "csiphy0_clk_mux" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY1 */
@@ -157,7 +168,9 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
{ 100000000, 200000000, 266666667 } },
.reg = { "csiphy1", "csiphy1_clk_mux" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY2 */
@@ -170,7 +183,9 @@ static const struct camss_subdev_resources csiphy_res_8x96[] = {
{ 100000000, 200000000, 266666667 } },
.reg = { "csiphy2", "csiphy2_clk_mux" },
.interrupt = { "csiphy2" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
}
};
@@ -190,7 +205,9 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
{ 0 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_4_7,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID1 */
@@ -208,7 +225,9 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
{ 0 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_4_7,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID2 */
@@ -226,7 +245,9 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
{ 0 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
- .ops = &csid_ops_4_7,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID3 */
@@ -244,7 +265,9 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
{ 0 } },
.reg = { "csid3" },
.interrupt = { "csid3" },
- .ops = &csid_ops_4_7,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
}
};
@@ -257,7 +280,7 @@ static const struct camss_subdev_resources ispif_res_8x96 = {
"csi3", "csi3_pix", "csi3_rdi" },
.clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" },
.reg = { "ispif", "csi_clk_mux" },
- .interrupt = { "ispif" }
+ .interrupt = { "ispif" },
};
static const struct camss_subdev_resources vfe_res_8x96[] = {
@@ -277,9 +300,11 @@ static const struct camss_subdev_resources vfe_res_8x96[] = {
{ 0 } },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_4_7
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_4_7
+ }
},
/* VFE1 */
@@ -298,9 +323,11 @@ static const struct camss_subdev_resources vfe_res_8x96[] = {
{ 0 } },
.reg = { "vfe1" },
.interrupt = { "vfe1" },
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_4_7
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_4_7
+ }
}
};
@@ -317,7 +344,9 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
{ 0 } },
.reg = { "csiphy0", "csiphy0_clk_mux" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY1 */
@@ -332,7 +361,9 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
{ 0 } },
.reg = { "csiphy1", "csiphy1_clk_mux" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY2 */
@@ -347,7 +378,9 @@ static const struct camss_subdev_resources csiphy_res_660[] = {
{ 0 } },
.reg = { "csiphy2", "csiphy2_clk_mux" },
.interrupt = { "csiphy2" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
}
};
@@ -370,7 +403,9 @@ static const struct camss_subdev_resources csid_res_660[] = {
{ 0 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_4_7,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID1 */
@@ -391,7 +426,9 @@ static const struct camss_subdev_resources csid_res_660[] = {
{ 0 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_4_7,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID2 */
@@ -412,7 +449,9 @@ static const struct camss_subdev_resources csid_res_660[] = {
{ 0 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
- .ops = &csid_ops_4_7,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
},
/* CSID3 */
@@ -433,7 +472,9 @@ static const struct camss_subdev_resources csid_res_660[] = {
{ 0 } },
.reg = { "csid3" },
.interrupt = { "csid3" },
- .ops = &csid_ops_4_7,
+ .csid = {
+ .hw_ops = &csid_ops_4_7
+ }
}
};
@@ -446,7 +487,7 @@ static const struct camss_subdev_resources ispif_res_660 = {
"csi3", "csi3_pix", "csi3_rdi" },
.clock_for_reset = { "vfe0", "csi_vfe0", "vfe1", "csi_vfe1" },
.reg = { "ispif", "csi_clk_mux" },
- .interrupt = { "ispif" }
+ .interrupt = { "ispif" },
};
static const struct camss_subdev_resources vfe_res_660[] = {
@@ -469,9 +510,11 @@ static const struct camss_subdev_resources vfe_res_660[] = {
{ 0 } },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_4_8
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_4_8
+ }
},
/* VFE1 */
@@ -493,9 +536,11 @@ static const struct camss_subdev_resources vfe_res_660[] = {
{ 0 } },
.reg = { "vfe1" },
.interrupt = { "vfe1" },
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_4_8
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_4_8
+ }
}
};
@@ -516,7 +561,9 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
{ 19200000, 240000000, 269333333 } },
.reg = { "csiphy0" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY1 */
@@ -535,7 +582,9 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
{ 19200000, 240000000, 269333333 } },
.reg = { "csiphy1" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY2 */
@@ -554,7 +603,9 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
{ 19200000, 240000000, 269333333 } },
.reg = { "csiphy2" },
.interrupt = { "csiphy2" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY3 */
@@ -573,7 +624,9 @@ static const struct camss_subdev_resources csiphy_res_845[] = {
{ 19200000, 240000000, 269333333 } },
.reg = { "csiphy3" },
.interrupt = { "csiphy3" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
}
};
@@ -596,7 +649,9 @@ static const struct camss_subdev_resources csid_res_845[] = {
{ 384000000 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID1 */
@@ -617,7 +672,9 @@ static const struct camss_subdev_resources csid_res_845[] = {
{ 384000000 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID2 */
@@ -638,8 +695,10 @@ static const struct camss_subdev_resources csid_res_845[] = {
{ 384000000 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
}
};
@@ -662,9 +721,11 @@ static const struct camss_subdev_resources vfe_res_845[] = {
{ 384000000 } },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .line_num = 4,
- .has_pd = true,
- .ops = &vfe_ops_170
+ .vfe = {
+ .line_num = 4,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE1 */
@@ -685,9 +746,11 @@ static const struct camss_subdev_resources vfe_res_845[] = {
{ 384000000 } },
.reg = { "vfe1" },
.interrupt = { "vfe1" },
- .line_num = 4,
- .has_pd = true,
- .ops = &vfe_ops_170
+ .vfe = {
+ .line_num = 4,
+ .has_pd = true,
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE-lite */
@@ -707,9 +770,11 @@ static const struct camss_subdev_resources vfe_res_845[] = {
{ 384000000 } },
.reg = { "vfe_lite" },
.interrupt = { "vfe_lite" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_170
+ }
}
};
@@ -722,7 +787,9 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy0" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY1 */
{
@@ -732,7 +799,9 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy1" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY2 */
{
@@ -742,7 +811,9 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy2" },
.interrupt = { "csiphy2" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY3 */
{
@@ -752,7 +823,9 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy3" },
.interrupt = { "csiphy3" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY4 */
{
@@ -762,7 +835,9 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy4" },
.interrupt = { "csiphy4" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY5 */
{
@@ -772,7 +847,9 @@ static const struct camss_subdev_resources csiphy_res_8250[] = {
{ 300000000 } },
.reg = { "csiphy5" },
.interrupt = { "csiphy5" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
}
};
@@ -788,7 +865,9 @@ static const struct camss_subdev_resources csid_res_8250[] = {
{ 0 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID1 */
{
@@ -801,7 +880,9 @@ static const struct camss_subdev_resources csid_res_8250[] = {
{ 0 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID2 */
{
@@ -813,8 +894,10 @@ static const struct camss_subdev_resources csid_res_8250[] = {
{ 0 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID3 */
{
@@ -826,8 +909,10 @@ static const struct camss_subdev_resources csid_res_8250[] = {
{ 0 } },
.reg = { "csid3" },
.interrupt = { "csid3" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
}
};
@@ -849,10 +934,12 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
{ 0 } },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .pd_name = "ife0",
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_480
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .pd_name = "ife0",
+ .hw_ops = &vfe_ops_480
+ }
},
/* VFE1 */
{
@@ -871,10 +958,12 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
{ 0 } },
.reg = { "vfe1" },
.interrupt = { "vfe1" },
- .pd_name = "ife1",
- .line_num = 3,
- .has_pd = true,
- .ops = &vfe_ops_480
+ .vfe = {
+ .line_num = 3,
+ .has_pd = true,
+ .pd_name = "ife1",
+ .hw_ops = &vfe_ops_480
+ }
},
/* VFE2 (lite) */
{
@@ -892,9 +981,11 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
{ 0 } },
.reg = { "vfe_lite0" },
.interrupt = { "vfe_lite0" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_480
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_480
+ }
},
/* VFE3 (lite) */
{
@@ -912,9 +1003,11 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
{ 0 } },
.reg = { "vfe_lite1" },
.interrupt = { "vfe_lite1" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_480
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_480
+ }
},
};
@@ -950,7 +1043,9 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
{ 300000000 } },
.reg = { "csiphy0" },
.interrupt = { "csiphy0" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY1 */
{
@@ -960,7 +1055,9 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
{ 300000000 } },
.reg = { "csiphy1" },
.interrupt = { "csiphy1" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY2 */
{
@@ -970,7 +1067,9 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
{ 300000000 } },
.reg = { "csiphy2" },
.interrupt = { "csiphy2" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
/* CSIPHY3 */
{
@@ -980,7 +1079,9 @@ static const struct camss_subdev_resources csiphy_res_sc8280xp[] = {
{ 300000000 } },
.reg = { "csiphy3" },
.interrupt = { "csiphy3" },
- .ops = &csiphy_ops_3ph_1_0
+ .csiphy = {
+ .hw_ops = &csiphy_ops_3ph_1_0
+ }
},
};
@@ -995,7 +1096,9 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 } },
.reg = { "csid0" },
.interrupt = { "csid0" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID1 */
{
@@ -1007,7 +1110,9 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 } },
.reg = { "csid1" },
.interrupt = { "csid1" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID2 */
{
@@ -1019,7 +1124,9 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 } },
.reg = { "csid2" },
.interrupt = { "csid2" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID3 */
{
@@ -1031,7 +1138,9 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 } },
.reg = { "csid3" },
.interrupt = { "csid3" },
- .ops = &csid_ops_gen2
+ .csid = {
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID_LITE0 */
{
@@ -1042,8 +1151,10 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 }, },
.reg = { "csid0_lite" },
.interrupt = { "csid0_lite" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID_LITE1 */
{
@@ -1054,8 +1165,10 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 }, },
.reg = { "csid1_lite" },
.interrupt = { "csid1_lite" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID_LITE2 */
{
@@ -1066,8 +1179,10 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 }, },
.reg = { "csid2_lite" },
.interrupt = { "csid2_lite" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
},
/* CSID_LITE3 */
{
@@ -1078,8 +1193,10 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
{ 0 }, },
.reg = { "csid3_lite" },
.interrupt = { "csid3_lite" },
- .is_lite = true,
- .ops = &csid_ops_gen2
+ .csid = {
+ .is_lite = true,
+ .hw_ops = &csid_ops_gen2
+ }
}
};
@@ -1096,9 +1213,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 0 }, },
.reg = { "vfe0" },
.interrupt = { "vfe0" },
- .pd_name = "ife0",
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .line_num = 4,
+ .pd_name = "ife0",
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE1 */
{
@@ -1112,9 +1231,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 0 }, },
.reg = { "vfe1" },
.interrupt = { "vfe1" },
- .pd_name = "ife1",
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .line_num = 4,
+ .pd_name = "ife1",
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE2 */
{
@@ -1128,9 +1249,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 0 }, },
.reg = { "vfe2" },
.interrupt = { "vfe2" },
- .pd_name = "ife2",
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .line_num = 4,
+ .pd_name = "ife2",
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE3 */
{
@@ -1144,9 +1267,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 0 }, },
.reg = { "vfe3" },
.interrupt = { "vfe3" },
- .pd_name = "ife3",
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .line_num = 4,
+ .pd_name = "ife3",
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE_LITE_0 */
{
@@ -1159,9 +1284,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 320000000, 400000000, 480000000, 600000000 }, },
.reg = { "vfe_lite0" },
.interrupt = { "vfe_lite0" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE_LITE_1 */
{
@@ -1174,9 +1301,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 320000000, 400000000, 480000000, 600000000 }, },
.reg = { "vfe_lite1" },
.interrupt = { "vfe_lite1" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE_LITE_2 */
{
@@ -1189,9 +1318,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 320000000, 400000000, 480000000, 600000000, }, },
.reg = { "vfe_lite2" },
.interrupt = { "vfe_lite2" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_170
+ }
},
/* VFE_LITE_3 */
{
@@ -1204,9 +1335,11 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
{ 320000000, 400000000, 480000000, 600000000 }, },
.reg = { "vfe_lite3" },
.interrupt = { "vfe_lite3" },
- .is_lite = true,
- .line_num = 4,
- .ops = &vfe_ops_170
+ .vfe = {
+ .is_lite = true,
+ .line_num = 4,
+ .hw_ops = &vfe_ops_170
+ }
},
};
@@ -1375,7 +1508,7 @@ int camss_pm_domain_on(struct camss *camss, int id)
if (id < camss->res->vfe_num) {
struct vfe_device *vfe = &camss->vfe[id];
- ret = vfe->ops->pm_domain_on(vfe);
+ ret = vfe->res->hw_ops->pm_domain_on(vfe);
}
return ret;
@@ -1386,7 +1519,7 @@ void camss_pm_domain_off(struct camss *camss, int id)
if (id < camss->res->vfe_num) {
struct vfe_device *vfe = &camss->vfe[id];
- vfe->ops->pm_domain_off(vfe);
+ vfe->res->hw_ops->pm_domain_off(vfe);
}
}
@@ -1628,7 +1761,7 @@ static int camss_register_entities(struct camss *camss)
for (i = 0; i < camss->ispif->line_num; i++)
for (k = 0; k < camss->res->vfe_num; k++)
- for (j = 0; j < camss->vfe[k].line_num; j++) {
+ for (j = 0; j < camss->vfe[k].res->line_num; j++) {
struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev;
struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
@@ -1649,7 +1782,7 @@ static int camss_register_entities(struct camss *camss)
} else {
for (i = 0; i < camss->res->csid_num; i++)
for (k = 0; k < camss->res->vfe_num; k++)
- for (j = 0; j < camss->vfe[k].line_num; j++) {
+ for (j = 0; j < camss->vfe[k].res->line_num; j++) {
struct v4l2_subdev *csid = &camss->csid[i].subdev;
struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
@@ -1810,7 +1943,7 @@ static int camss_configure_pd(struct camss *camss)
/* count the # of VFEs which have flagged power-domain */
for (vfepd_num = i = 0; i < camss->res->vfe_num; i++) {
- if (res->vfe_res[i].has_pd)
+ if (res->vfe_res[i].vfe.has_pd)
vfepd_num++;
}
diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
index ac15fe23a702e..e6d9fba646a10 100644
--- a/drivers/media/platform/qcom/camss/camss.h
+++ b/drivers/media/platform/qcom/camss/camss.h
@@ -48,11 +48,11 @@ struct camss_subdev_resources {
u32 clock_rate[CAMSS_RES_MAX][CAMSS_RES_MAX];
char *reg[CAMSS_RES_MAX];
char *interrupt[CAMSS_RES_MAX];
- char *pd_name;
- u8 line_num;
- bool has_pd;
- bool is_lite;
- const void *ops;
+ union {
+ struct csiphy_subdev_resources csiphy;
+ struct csid_subdev_resources csid;
+ struct vfe_subdev_resources vfe;
+ };
};
struct icc_bw_tbl {
--
2.43.0
On 5/11/2024 1:18 AM, Bryan O'Donoghue wrote:
> On 11/04/2024 13:45, Gjorgji Rosikopulos wrote:
>> + .type = CAMSS_SUBDEV_TYPE_CSIPHY,
>
> As Matti pointed out to me on IRC, the .type value here isn't populated
> in the rest of the 8280xp resources.
>
> I completely missed that but, then again this appears to be a dead field
> in this series so it makes no difference if it is populated.
>
> I realise it is probably of use in code you _haven't_ yet published but,
> for now I think we should drop this field, since its dead code.
Yes that is correct i miss that as well.
>
> I'll send a fixup patch for this, I don't think there's a need for you
> to send the whole series again.
Thank you for this.
~Gjorgji
>
> ---
> bod
On 4/11/24 15:45, Gjorgji Rosikopulos wrote:
> From: Radoslav Tsvetkov <[email protected]>
>
> Video node formats have direct dependency by the sub-device pad formats.
> Remove dependency for SoC version and move format definitions in device
> which creates video node.
>
> This commit attaches a struct to the VFE resources that holds format
> description, so it is much easier to assign them to the video node.
> No need to use a switch-case.
>
> NOTE: The mbus_bpp is used to calculate the clock rates and is different
> from bpp which is the bits per pixel written to memory. We need to keep
> both values to not break the calcualtions.
>
> Signed-off-by: Radoslav Tsvetkov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
> .../media/platform/qcom/camss/camss-format.h | 62 +++
> drivers/media/platform/qcom/camss/camss-vfe.c | 359 ++++++++++++------
> drivers/media/platform/qcom/camss/camss-vfe.h | 11 +-
> .../media/platform/qcom/camss/camss-video.c | 269 +------------
> .../media/platform/qcom/camss/camss-video.h | 5 +-
> drivers/media/platform/qcom/camss/camss.c | 80 +++-
> drivers/media/platform/qcom/camss/camss.h | 1 +
> 7 files changed, 383 insertions(+), 404 deletions(-)
> create mode 100644 drivers/media/platform/qcom/camss/camss-format.h
>
> diff --git a/drivers/media/platform/qcom/camss/camss-format.h b/drivers/media/platform/qcom/camss/camss-format.h
> new file mode 100644
> index 000000000000..bfbc761bd46c
> --- /dev/null
> +++ b/drivers/media/platform/qcom/camss/camss-format.h
> @@ -0,0 +1,62 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/* Copyright (c) 2023, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2023 Qualcomm Technologies, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
The given SPDX-License-Identifier tag is sufficient to describe the licence,
so all the lines above but the first one are redundant and should be removed.
> +#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)
> +
> +#ifndef __CAMSS_FORMAT_H__
> +#define __CAMSS_FORMAT_H__
> +
PER_PLANE_DATA macro declaration shall be put under __CAMSS_FORMAT_H__ macro guard,
otherwise the macro guard does not work as expected, you'll get compile time issues,
if you enter some kind of a header include collision.
> +#include <linux/types.h>
> +
> +/*
> + * 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;
> +};
> +
Please note a "struct v4l2_fract" and find the next comment.
I see that the structure is moved from "camss-video.c", to some extent it
might be acceptable to keep it .c file, but probably it's better to replace
it in a header file.
> +/*
> + * 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
Apparently and according to the comments above the header file references
to V4L2 specific structures and types. So, I'd say it makes a sense to
reuse V4L2 code rather than redefining it.
> + * @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 plane {
struct fract hsub;
struct fract vsub;
unsigned int bpp;
}
and then define an array of planes, plance argument will go away from the macro in
the beginning of the file.
> +};
> +
> +struct camss_formats {
> + unsigned int nformats;
> + const struct camss_format_info *formats;
> +};
> +
> +#endif /* __CAMSS_FORMAT_H__ */
> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
> index 459c70a4b319..2d5a64c055f1 100644
> --- a/drivers/media/platform/qcom/camss/camss-vfe.c
> +++ b/drivers/media/platform/qcom/camss/camss-vfe.c
> @@ -32,96 +32,250 @@
>
> #define SCALER_RATIO_MAX 16
>
> -struct vfe_format {
> - u32 code;
> - u8 bpp;
> +static const struct camss_format_info formats_rdi_8x16[] = {
> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_SBGGR8_1X8, 8, V4L2_PIX_FMT_SBGGR8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SGBRG8_1X8, 8, V4L2_PIX_FMT_SGBRG8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SGRBG8_1X8, 8, V4L2_PIX_FMT_SGRBG8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SRGGB8_1X8, 8, V4L2_PIX_FMT_SRGGB8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SBGGR10_1X10, 10, V4L2_PIX_FMT_SBGGR10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SGBRG10_1X10, 10, V4L2_PIX_FMT_SGBRG10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SGRBG10_1X10, 10, V4L2_PIX_FMT_SGRBG10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SRGGB10_1X10, 10, V4L2_PIX_FMT_SRGGB10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SBGGR12_1X12, 12, V4L2_PIX_FMT_SBGGR12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SGBRG12_1X12, 12, V4L2_PIX_FMT_SGBRG12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SGRBG12_1X12, 12, V4L2_PIX_FMT_SGRBG12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SRGGB12_1X12, 12, V4L2_PIX_FMT_SRGGB12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_Y10_1X10, 10, V4L2_PIX_FMT_Y10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> +};
> +
> +static const struct camss_format_info formats_rdi_8x96[] = {
> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_SBGGR8_1X8, 8, V4L2_PIX_FMT_SBGGR8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SGBRG8_1X8, 8, V4L2_PIX_FMT_SGBRG8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SGRBG8_1X8, 8, V4L2_PIX_FMT_SGRBG8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SRGGB8_1X8, 8, V4L2_PIX_FMT_SRGGB8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SBGGR10_1X10, 10, V4L2_PIX_FMT_SBGGR10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SGBRG10_1X10, 10, V4L2_PIX_FMT_SGBRG10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SGRBG10_1X10, 10, V4L2_PIX_FMT_SGRBG10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SRGGB10_1X10, 10, V4L2_PIX_FMT_SRGGB10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_SBGGR10, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_SBGGR12_1X12, 12, V4L2_PIX_FMT_SBGGR12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SGBRG12_1X12, 12, V4L2_PIX_FMT_SGBRG12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SGRBG12_1X12, 12, V4L2_PIX_FMT_SGRBG12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SRGGB12_1X12, 12, V4L2_PIX_FMT_SRGGB12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SBGGR14_1X14, 14, V4L2_PIX_FMT_SBGGR14P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
> + { MEDIA_BUS_FMT_SGBRG14_1X14, 14, V4L2_PIX_FMT_SGBRG14P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
> + { MEDIA_BUS_FMT_SGRBG14_1X14, 14, V4L2_PIX_FMT_SGRBG14P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
> + { MEDIA_BUS_FMT_SRGGB14_1X14, 14, V4L2_PIX_FMT_SRGGB14P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
> + { MEDIA_BUS_FMT_Y10_1X10, 10, V4L2_PIX_FMT_Y10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_Y10, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> +};
> +
> +static const struct camss_format_info formats_rdi_845[] = {
> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_SBGGR8_1X8, 8, V4L2_PIX_FMT_SBGGR8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SGBRG8_1X8, 8, V4L2_PIX_FMT_SGBRG8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SGRBG8_1X8, 8, V4L2_PIX_FMT_SGRBG8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SRGGB8_1X8, 8, V4L2_PIX_FMT_SRGGB8, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_SBGGR10_1X10, 10, V4L2_PIX_FMT_SBGGR10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SGBRG10_1X10, 10, V4L2_PIX_FMT_SGBRG10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SGRBG10_1X10, 10, V4L2_PIX_FMT_SGRBG10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SRGGB10_1X10, 10, V4L2_PIX_FMT_SRGGB10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_SBGGR10, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_SBGGR12_1X12, 12, V4L2_PIX_FMT_SBGGR12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SGBRG12_1X12, 12, V4L2_PIX_FMT_SGBRG12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SGRBG12_1X12, 12, V4L2_PIX_FMT_SGRBG12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SRGGB12_1X12, 12, V4L2_PIX_FMT_SRGGB12P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
> + { MEDIA_BUS_FMT_SBGGR14_1X14, 14, V4L2_PIX_FMT_SBGGR14P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
> + { MEDIA_BUS_FMT_SGBRG14_1X14, 14, V4L2_PIX_FMT_SGBRG14P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
> + { MEDIA_BUS_FMT_SGRBG14_1X14, 14, V4L2_PIX_FMT_SGRBG14P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
> + { MEDIA_BUS_FMT_SRGGB14_1X14, 14, V4L2_PIX_FMT_SRGGB14P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
> + { MEDIA_BUS_FMT_Y8_1X8, 8, V4L2_PIX_FMT_GREY, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
> + { MEDIA_BUS_FMT_Y10_1X10, 10, V4L2_PIX_FMT_Y10P, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
> + { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_Y10, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> +};
> +
> +static const struct camss_format_info formats_pix_8x16[] = {
> + { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> +};
> +
> +static const struct camss_format_info formats_pix_8x96[] = {
> + { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
> +};
> +
> +const struct camss_formats vfe_formats_rdi_8x16 = {
> + .nformats = ARRAY_SIZE(formats_rdi_8x16),
> + .formats = formats_rdi_8x16
> };
>
> -static const struct vfe_format formats_rdi_8x16[] = {
> - { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
> - { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
> - { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
> - { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
> - { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
> - { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
> - { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
> - { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
> - { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
> - { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
> - { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
> - { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
> - { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
> - { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
> - { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
> - { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
> - { MEDIA_BUS_FMT_Y10_1X10, 10 },
> +const struct camss_formats vfe_formats_pix_8x16 = {
> + .nformats = ARRAY_SIZE(formats_pix_8x16),
> + .formats = formats_pix_8x16
> };
>
> -static const struct vfe_format formats_pix_8x16[] = {
> - { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
> - { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
> - { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
> - { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
> +const struct camss_formats vfe_formats_rdi_8x96 = {
> + .nformats = ARRAY_SIZE(formats_rdi_8x96),
> + .formats = formats_rdi_8x96
> };
>
> -static const struct vfe_format formats_rdi_8x96[] = {
> - { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
> - { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
> - { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
> - { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
> - { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
> - { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
> - { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
> - { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
> - { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
> - { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
> - { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
> - { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
> - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16 },
> - { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
> - { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
> - { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
> - { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
> - { MEDIA_BUS_FMT_SBGGR14_1X14, 14 },
> - { MEDIA_BUS_FMT_SGBRG14_1X14, 14 },
> - { MEDIA_BUS_FMT_SGRBG14_1X14, 14 },
> - { MEDIA_BUS_FMT_SRGGB14_1X14, 14 },
> - { MEDIA_BUS_FMT_Y10_1X10, 10 },
> - { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16 },
> +const struct camss_formats vfe_formats_pix_8x96 = {
> + .nformats = ARRAY_SIZE(formats_pix_8x96),
> + .formats = formats_pix_8x96
> };
>
> -static const struct vfe_format formats_pix_8x96[] = {
> - { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
> - { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
> - { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
> - { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
> +const struct camss_formats vfe_formats_rdi_845 = {
> + .nformats = ARRAY_SIZE(formats_rdi_845),
> + .formats = formats_rdi_845
> };
>
> -static const struct vfe_format formats_rdi_845[] = {
> - { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
> - { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
> - { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
> - { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
> - { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
> - { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
> - { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
> - { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
> - { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
> - { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
> - { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
> - { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
> - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16 },
> - { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
> - { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
> - { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
> - { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
> - { MEDIA_BUS_FMT_SBGGR14_1X14, 14 },
> - { MEDIA_BUS_FMT_SGBRG14_1X14, 14 },
> - { MEDIA_BUS_FMT_SGRBG14_1X14, 14 },
> - { MEDIA_BUS_FMT_SRGGB14_1X14, 14 },
> - { MEDIA_BUS_FMT_Y8_1X8, 8 },
> - { MEDIA_BUS_FMT_Y10_1X10, 10 },
> - { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16 },
> +/* TODO: Replace with pix formats */
> +const struct camss_formats vfe_formats_pix_845 = {
> + .nformats = ARRAY_SIZE(formats_rdi_845),
> + .formats = formats_rdi_845
> };
>
> /*
> @@ -132,18 +286,18 @@ static const struct vfe_format formats_rdi_845[] = {
> *
> * Return number of bits per pixel
> */
> -static u8 vfe_get_bpp(const struct vfe_format *formats,
> +static u8 vfe_get_bpp(const struct camss_format_info *formats,
> unsigned int nformats, u32 code)
> {
> unsigned int i;
>
> for (i = 0; i < nformats; i++)
> if (code == formats[i].code)
> - return formats[i].bpp;
> + return formats[i].mbus_bpp;
>
> WARN(1, "Unknown format\n");
>
> - return formats[0].bpp;
> + return formats[0].mbus_bpp;
> }
>
> static u32 vfe_find_code(u32 *code, unsigned int n_code,
> @@ -1495,32 +1649,12 @@ int msm_vfe_subdev_init(struct camss *camss, struct vfe_device *vfe,
> init_completion(&l->output.sof);
> init_completion(&l->output.reg_update);
>
> - switch (camss->res->version) {
> - case CAMSS_8x16:
> - if (i == VFE_LINE_PIX) {
> - l->formats = formats_pix_8x16;
> - l->nformats = ARRAY_SIZE(formats_pix_8x16);
> - } else {
> - l->formats = formats_rdi_8x16;
> - l->nformats = ARRAY_SIZE(formats_rdi_8x16);
> - }
> - break;
> - case CAMSS_8x96:
> - case CAMSS_660:
> - if (i == VFE_LINE_PIX) {
> - l->formats = formats_pix_8x96;
> - l->nformats = ARRAY_SIZE(formats_pix_8x96);
> - } else {
> - l->formats = formats_rdi_8x96;
> - l->nformats = ARRAY_SIZE(formats_rdi_8x96);
> - }
> - break;
> - case CAMSS_845:
> - case CAMSS_8250:
> - case CAMSS_8280XP:
> - l->formats = formats_rdi_845;
> - l->nformats = ARRAY_SIZE(formats_rdi_845);
> - break;
> + if (i == VFE_LINE_PIX) {
> + l->nformats = res->vfe.formats_pix->nformats;
> + l->formats = res->vfe.formats_pix->formats;
> + } else {
> + l->nformats = res->vfe.formats_rdi->nformats;
> + l->formats = res->vfe.formats_rdi->formats;
> }
> }
>
> @@ -1684,10 +1818,13 @@ int msm_vfe_register_entities(struct vfe_device *vfe,
> video_out->bpl_alignment = 16;
> video_out->line_based = 1;
> }
> +
> + video_out->nformats = vfe->line[i].nformats;
> + video_out->formats = vfe->line[i].formats;
> +
> snprintf(name, ARRAY_SIZE(name), "%s%d_%s%d",
> MSM_VFE_NAME, vfe->id, "video", i);
> - ret = msm_video_register(video_out, v4l2_dev, name,
> - i == VFE_LINE_PIX ? 1 : 0);
> + ret = msm_video_register(video_out, v4l2_dev, name);
> if (ret < 0) {
> dev_err(dev, "Failed to register video node: %d\n",
> ret);
> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h b/drivers/media/platform/qcom/camss/camss-vfe.h
> index 87fc159c48cc..10e2cc3c0b83 100644
> --- a/drivers/media/platform/qcom/camss/camss-vfe.h
> +++ b/drivers/media/platform/qcom/camss/camss-vfe.h
> @@ -92,7 +92,7 @@ struct vfe_line {
> struct v4l2_rect crop;
> struct camss_video video_out;
> struct vfe_output output;
> - const struct vfe_format *formats;
> + const struct camss_format_info *formats;
> unsigned int nformats;
> };
>
> @@ -132,6 +132,8 @@ struct vfe_subdev_resources {
> bool has_pd;
> char *pd_name;
> const struct vfe_hw_ops *hw_ops;
> + const struct camss_formats *formats_rdi;
> + const struct camss_formats *formats_pix;
> };
>
> struct vfe_device {
> @@ -224,6 +226,13 @@ void vfe_pm_domain_off(struct vfe_device *vfe);
> */
> int vfe_pm_domain_on(struct vfe_device *vfe);
>
> +extern const struct camss_formats vfe_formats_rdi_8x16;
> +extern const struct camss_formats vfe_formats_pix_8x16;
> +extern const struct camss_formats vfe_formats_rdi_8x96;
> +extern const struct camss_formats vfe_formats_pix_8x96;
> +extern const struct camss_formats vfe_formats_rdi_845;
> +extern const struct camss_formats vfe_formats_pix_845;
> +
> extern const struct vfe_hw_ops vfe_ops_4_1;
> extern const struct vfe_hw_ops vfe_ops_4_7;
> extern const struct vfe_hw_ops vfe_ops_4_8;
> diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
> index 54cd82f74115..cd13a432e291 100644
> --- a/drivers/media/platform/qcom/camss/camss-video.c
> +++ b/drivers/media/platform/qcom/camss/camss-video.c
> @@ -24,244 +24,6 @@
> #define CAMSS_FRAME_MAX_HEIGHT_RDI 8191
> #define CAMSS_FRAME_MAX_HEIGHT_PIX 4096
>
> -struct fract {
> - u8 numerator;
> - u8 denominator;
> -};
> -
> -/*
> - * struct camss_format_info - ISP media bus format information
> - * @code: V4L2 media bus format code
> - * @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 pixelformat;
> - u8 planes;
> - struct fract hsub[3];
> - struct fract vsub[3];
> - unsigned int bpp[3];
> -};
> -
> -static const struct camss_format_info formats_rdi_8x16[] = {
> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_PIX_FMT_SBGGR8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_PIX_FMT_SGBRG8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_PIX_FMT_SGRBG8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_PIX_FMT_SRGGB8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> -};
> -
> -static const struct camss_format_info formats_rdi_8x96[] = {
> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_PIX_FMT_SBGGR8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_PIX_FMT_SGBRG8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_PIX_FMT_SGRBG8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_PIX_FMT_SRGGB8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_PIX_FMT_SBGGR10, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SBGGR14_1X14, V4L2_PIX_FMT_SBGGR14P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
> - { MEDIA_BUS_FMT_SGBRG14_1X14, V4L2_PIX_FMT_SGBRG14P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
> - { MEDIA_BUS_FMT_SGRBG14_1X14, V4L2_PIX_FMT_SGRBG14P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
> - { MEDIA_BUS_FMT_SRGGB14_1X14, V4L2_PIX_FMT_SRGGB14P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
> - { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, V4L2_PIX_FMT_Y10, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> -};
> -
> -static const struct camss_format_info formats_rdi_845[] = {
> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_PIX_FMT_SBGGR8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_PIX_FMT_SGBRG8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_PIX_FMT_SGRBG8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_PIX_FMT_SRGGB8, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_PIX_FMT_SBGGR10, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
> - { MEDIA_BUS_FMT_SBGGR14_1X14, V4L2_PIX_FMT_SBGGR14P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
> - { MEDIA_BUS_FMT_SGBRG14_1X14, V4L2_PIX_FMT_SGBRG14P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
> - { MEDIA_BUS_FMT_SGRBG14_1X14, V4L2_PIX_FMT_SGRBG14P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
> - { MEDIA_BUS_FMT_SRGGB14_1X14, V4L2_PIX_FMT_SRGGB14P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
> - { MEDIA_BUS_FMT_Y8_1X8, V4L2_PIX_FMT_GREY, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
> - { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
> - { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, V4L2_PIX_FMT_Y10, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> -};
> -
> -static const struct camss_format_info formats_pix_8x16[] = {
> - { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV12, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV12, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV21, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV21, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV16, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV16, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV16, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV16, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV61, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV61, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV61, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV61, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> -};
> -
> -static const struct camss_format_info formats_pix_8x96[] = {
> - { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV12, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV12, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV21, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV21, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV16, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV16, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV16, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV16, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV61, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV61, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV61, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV61, 1,
> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
> -};
> -
> /* -----------------------------------------------------------------------------
> * Helper functions
> */
> @@ -968,8 +730,7 @@ static int msm_video_init_format(struct camss_video *video)
> * Return 0 on success or a negative error code otherwise
> */
>
> -int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
> - const char *name, int is_pix)
> +int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, const char *name)
Please wrap the line above.
> {
> struct media_pad *pad = &video->pad;
> struct video_device *vdev;
> @@ -1006,34 +767,6 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
>
> mutex_init(&video->lock);
>
> - switch (video->camss->res->version) {
> - case CAMSS_8x16:
> - if (is_pix) {
> - video->formats = formats_pix_8x16;
> - video->nformats = ARRAY_SIZE(formats_pix_8x16);
> - } else {
> - video->formats = formats_rdi_8x16;
> - video->nformats = ARRAY_SIZE(formats_rdi_8x16);
> - }
> - break;
> - case CAMSS_8x96:
> - case CAMSS_660:
> - if (is_pix) {
> - video->formats = formats_pix_8x96;
> - video->nformats = ARRAY_SIZE(formats_pix_8x96);
> - } else {
> - video->formats = formats_rdi_8x96;
> - video->nformats = ARRAY_SIZE(formats_rdi_8x96);
> - }
> - break;
> - case CAMSS_845:
> - case CAMSS_8250:
> - case CAMSS_8280XP:
> - video->formats = formats_rdi_845;
> - video->nformats = ARRAY_SIZE(formats_rdi_845);
> - break;
> - }
> -
> ret = msm_video_init_format(video);
> if (ret < 0) {
> dev_err(v4l2_dev->dev, "Failed to init format: %d\n", ret);
> diff --git a/drivers/media/platform/qcom/camss/camss-video.h b/drivers/media/platform/qcom/camss/camss-video.h
> index bdbae8424140..4f6c0821ead2 100644
> --- a/drivers/media/platform/qcom/camss/camss-video.h
> +++ b/drivers/media/platform/qcom/camss/camss-video.h
> @@ -33,8 +33,6 @@ struct camss_video_ops {
> enum vb2_buffer_state state);
> };
>
> -struct camss_format_info;
> -
> struct camss_video {
> struct camss *camss;
> struct vb2_queue vb2_q;
> @@ -52,8 +50,7 @@ struct camss_video {
> unsigned int nformats;
> };
>
> -int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
> - const char *name, int is_pix);
> +int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, const char *name);
Please wrap the line above.
>
> void msm_video_unregister(struct camss_video *video);
>
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index e4ae81dc9a15..f3242d2d9807 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -143,7 +143,9 @@ static const struct camss_subdev_resources vfe_res_8x16[] = {
> .type = CAMSS_SUBDEV_TYPE_VFE,
> .vfe = {
> .line_num = 3,
> - .hw_ops = &vfe_ops_4_1
> + .hw_ops = &vfe_ops_4_1,
> + .formats_rdi = &vfe_formats_rdi_8x16,
> + .formats_pix = &vfe_formats_pix_8x16
> }
> }
> };
> @@ -318,7 +320,9 @@ static const struct camss_subdev_resources vfe_res_8x96[] = {
> .vfe = {
> .line_num = 3,
> .has_pd = true,
> - .hw_ops = &vfe_ops_4_7
> + .hw_ops = &vfe_ops_4_7,
> + .formats_rdi = &vfe_formats_rdi_8x96,
> + .formats_pix = &vfe_formats_pix_8x96
> }
> },
>
> @@ -342,7 +346,9 @@ static const struct camss_subdev_resources vfe_res_8x96[] = {
> .vfe = {
> .line_num = 3,
> .has_pd = true,
> - .hw_ops = &vfe_ops_4_7
> + .hw_ops = &vfe_ops_4_7,
> + .formats_rdi = &vfe_formats_rdi_8x96,
> + .formats_pix = &vfe_formats_pix_8x96
> }
> }
> };
> @@ -538,7 +544,9 @@ static const struct camss_subdev_resources vfe_res_660[] = {
> .vfe = {
> .line_num = 3,
> .has_pd = true,
> - .hw_ops = &vfe_ops_4_8
> + .hw_ops = &vfe_ops_4_8,
> + .formats_rdi = &vfe_formats_rdi_8x96,
> + .formats_pix = &vfe_formats_pix_8x96
> }
> },
>
> @@ -565,7 +573,9 @@ static const struct camss_subdev_resources vfe_res_660[] = {
> .vfe = {
> .line_num = 3,
> .has_pd = true,
> - .hw_ops = &vfe_ops_4_8
> + .hw_ops = &vfe_ops_4_8,
> + .formats_rdi = &vfe_formats_rdi_8x96,
> + .formats_pix = &vfe_formats_pix_8x96
> }
> }
> };
> @@ -758,7 +768,9 @@ static const struct camss_subdev_resources vfe_res_845[] = {
> .vfe = {
> .line_num = 4,
> .has_pd = true,
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
>
> @@ -784,7 +796,9 @@ static const struct camss_subdev_resources vfe_res_845[] = {
> .vfe = {
> .line_num = 4,
> .has_pd = true,
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
>
> @@ -809,7 +823,9 @@ static const struct camss_subdev_resources vfe_res_845[] = {
> .vfe = {
> .is_lite = true,
> .line_num = 4,
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> }
> };
> @@ -985,7 +1001,9 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
> .line_num = 3,
> .has_pd = true,
> .pd_name = "ife0",
> - .hw_ops = &vfe_ops_480
> + .hw_ops = &vfe_ops_480,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> /* VFE1 */
> @@ -1010,7 +1028,9 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
> .line_num = 3,
> .has_pd = true,
> .pd_name = "ife1",
> - .hw_ops = &vfe_ops_480
> + .hw_ops = &vfe_ops_480,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> /* VFE2 (lite) */
> @@ -1033,7 +1053,9 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
> .vfe = {
> .is_lite = true,
> .line_num = 4,
> - .hw_ops = &vfe_ops_480
> + .hw_ops = &vfe_ops_480,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> /* VFE3 (lite) */
> @@ -1056,7 +1078,9 @@ static const struct camss_subdev_resources vfe_res_8250[] = {
> .vfe = {
> .is_lite = true,
> .line_num = 4,
> - .hw_ops = &vfe_ops_480
> + .hw_ops = &vfe_ops_480,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> };
> @@ -1267,7 +1291,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
> .vfe = {
> .line_num = 4,
> .pd_name = "ife0",
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> /* VFE1 */
> @@ -1285,7 +1311,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
> .vfe = {
> .line_num = 4,
> .pd_name = "ife1",
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> /* VFE2 */
> @@ -1303,7 +1331,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
> .vfe = {
> .line_num = 4,
> .pd_name = "ife2",
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> /* VFE3 */
> @@ -1321,7 +1351,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
> .vfe = {
> .line_num = 4,
> .pd_name = "ife3",
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> /* VFE_LITE_0 */
> @@ -1338,7 +1370,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
> .vfe = {
> .is_lite = true,
> .line_num = 4,
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> /* VFE_LITE_1 */
> @@ -1355,7 +1389,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
> .vfe = {
> .is_lite = true,
> .line_num = 4,
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> /* VFE_LITE_2 */
> @@ -1372,7 +1408,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
> .vfe = {
> .is_lite = true,
> .line_num = 4,
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> /* VFE_LITE_3 */
> @@ -1389,7 +1427,9 @@ static const struct camss_subdev_resources vfe_res_sc8280xp[] = {
> .vfe = {
> .is_lite = true,
> .line_num = 4,
> - .hw_ops = &vfe_ops_170
> + .hw_ops = &vfe_ops_170,
> + .formats_rdi = &vfe_formats_rdi_845,
> + .formats_pix = &vfe_formats_pix_845
> }
> },
> };
> diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
> index 2477821dfd85..4b13012940bf 100644
> --- a/drivers/media/platform/qcom/camss/camss.h
> +++ b/drivers/media/platform/qcom/camss/camss.h
> @@ -22,6 +22,7 @@
> #include "camss-csiphy.h"
> #include "camss-ispif.h"
> #include "camss-vfe.h"
> +#include "camss-format.h"
>
> #define to_camss(ptr_module) \
> container_of(ptr_module, struct camss, ptr_module)
--
Best wishes,
Vladimir
Hi Vladimir,
Thanks for the review.
On 5/13/2024 6:15 PM, Vladimir Zapolskiy wrote:
> On 4/11/24 15:45, Gjorgji Rosikopulos wrote:
>> From: Radoslav Tsvetkov <[email protected]>
>>
>> Video node formats have direct dependency by the sub-device pad formats.
>> Remove dependency for SoC version and move format definitions in device
>> which creates video node.
>>
>> This commit attaches a struct to the VFE resources that holds format
>> description, so it is much easier to assign them to the video node.
>> No need to use a switch-case.
>>
>> NOTE: The mbus_bpp is used to calculate the clock rates and is different
>> from bpp which is the bits per pixel written to memory. We need to keep
>> both values to not break the calcualtions.
>>
>> Signed-off-by: Radoslav Tsvetkov <[email protected]>
>> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
>> ---
>> .../media/platform/qcom/camss/camss-format.h | 62 +++
>> drivers/media/platform/qcom/camss/camss-vfe.c | 359 ++++++++++++------
>> drivers/media/platform/qcom/camss/camss-vfe.h | 11 +-
>> .../media/platform/qcom/camss/camss-video.c | 269 +------------
>> .../media/platform/qcom/camss/camss-video.h | 5 +-
>> drivers/media/platform/qcom/camss/camss.c | 80 +++-
>> drivers/media/platform/qcom/camss/camss.h | 1 +
>> 7 files changed, 383 insertions(+), 404 deletions(-)
>> create mode 100644 drivers/media/platform/qcom/camss/camss-format.h
>>
>> diff --git a/drivers/media/platform/qcom/camss/camss-format.h
>> b/drivers/media/platform/qcom/camss/camss-format.h
>> new file mode 100644
>> index 000000000000..bfbc761bd46c
>> --- /dev/null
>> +++ b/drivers/media/platform/qcom/camss/camss-format.h
>> @@ -0,0 +1,62 @@
>> +/* SPDX-License-Identifier: GPL-2.0-only */
>> +/* Copyright (c) 2023, The Linux Foundation. All rights reserved.
>> + * Copyright (c) 2023 Qualcomm Technologies, Inc.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 and
>> + * only version 2 as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + */
>> +
>
> The given SPDX-License-Identifier tag is sufficient to describe the
> licence,
> so all the lines above but the first one are redundant and should be
> removed.
>
>> +#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)
>> +
>> +#ifndef __CAMSS_FORMAT_H__
>> +#define __CAMSS_FORMAT_H__
>> +
>
> PER_PLANE_DATA macro declaration shall be put under __CAMSS_FORMAT_H__
> macro guard,
> otherwise the macro guard does not work as expected, you'll get compile
> time issues,
> if you enter some kind of a header include collision.
Ups it seems we miss this during the review. Thanks i will check with
Bryan, whether to resend the series.
>
>> +#include <linux/types.h>
>> +
>> +/*
>> + * 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;
>> +};
>> +
>
> Please note a "struct v4l2_fract" and find the next comment.
>
> I see that the structure is moved from "camss-video.c", to some extent it
> might be acceptable to keep it .c file, but probably it's better to replace
> it in a header file.
This is migrated code from camss-video.c as you noticed. For sure there
are other things to cleanup but i will propose to have next cleanup
series for that.
>
>> +/*
>> + * 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
>
> Apparently and according to the comments above the header file references
> to V4L2 specific structures and types. So, I'd say it makes a sense to
> reuse V4L2 code rather than redefining it.
>
>> + * @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 plane {
> struct fract hsub;
> struct fract vsub;
> unsigned int bpp;
> }
>
> and then define an array of planes, plance argument will go away from
> the macro in
> the beginning of the file.
I agree but i would propose to have next series for cleanup up patches,
Otherwise we will have to many changes across the files.
>
>> +};
>> +
>> +struct camss_formats {
>> + unsigned int nformats;
>> + const struct camss_format_info *formats;
>> +};
>> +
>> +#endif /* __CAMSS_FORMAT_H__ */
>> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c
>> b/drivers/media/platform/qcom/camss/camss-vfe.c
>> index 459c70a4b319..2d5a64c055f1 100644
>> --- a/drivers/media/platform/qcom/camss/camss-vfe.c
>> +++ b/drivers/media/platform/qcom/camss/camss-vfe.c
>> @@ -32,96 +32,250 @@
>> #define SCALER_RATIO_MAX 16
>> -struct vfe_format {
>> - u32 code;
>> - u8 bpp;
>> +static const struct camss_format_info formats_rdi_8x16[] = {
>> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_SBGGR8_1X8, 8, V4L2_PIX_FMT_SBGGR8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SGBRG8_1X8, 8, V4L2_PIX_FMT_SGBRG8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SGRBG8_1X8, 8, V4L2_PIX_FMT_SGRBG8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SRGGB8_1X8, 8, V4L2_PIX_FMT_SRGGB8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SBGGR10_1X10, 10, V4L2_PIX_FMT_SBGGR10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SGBRG10_1X10, 10, V4L2_PIX_FMT_SGBRG10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SGRBG10_1X10, 10, V4L2_PIX_FMT_SGRBG10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SRGGB10_1X10, 10, V4L2_PIX_FMT_SRGGB10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SBGGR12_1X12, 12, V4L2_PIX_FMT_SBGGR12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SGBRG12_1X12, 12, V4L2_PIX_FMT_SGBRG12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SGRBG12_1X12, 12, V4L2_PIX_FMT_SGRBG12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SRGGB12_1X12, 12, V4L2_PIX_FMT_SRGGB12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_Y10_1X10, 10, V4L2_PIX_FMT_Y10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> +};
>> +
>> +static const struct camss_format_info formats_rdi_8x96[] = {
>> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_SBGGR8_1X8, 8, V4L2_PIX_FMT_SBGGR8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SGBRG8_1X8, 8, V4L2_PIX_FMT_SGBRG8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SGRBG8_1X8, 8, V4L2_PIX_FMT_SGRBG8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SRGGB8_1X8, 8, V4L2_PIX_FMT_SRGGB8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SBGGR10_1X10, 10, V4L2_PIX_FMT_SBGGR10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SGBRG10_1X10, 10, V4L2_PIX_FMT_SGBRG10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SGRBG10_1X10, 10, V4L2_PIX_FMT_SGRBG10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SRGGB10_1X10, 10, V4L2_PIX_FMT_SRGGB10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_SBGGR10, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_SBGGR12_1X12, 12, V4L2_PIX_FMT_SBGGR12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SGBRG12_1X12, 12, V4L2_PIX_FMT_SGBRG12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SGRBG12_1X12, 12, V4L2_PIX_FMT_SGRBG12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SRGGB12_1X12, 12, V4L2_PIX_FMT_SRGGB12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SBGGR14_1X14, 14, V4L2_PIX_FMT_SBGGR14P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
>> + { MEDIA_BUS_FMT_SGBRG14_1X14, 14, V4L2_PIX_FMT_SGBRG14P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
>> + { MEDIA_BUS_FMT_SGRBG14_1X14, 14, V4L2_PIX_FMT_SGRBG14P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
>> + { MEDIA_BUS_FMT_SRGGB14_1X14, 14, V4L2_PIX_FMT_SRGGB14P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
>> + { MEDIA_BUS_FMT_Y10_1X10, 10, V4L2_PIX_FMT_Y10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_Y10, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> +};
>> +
>> +static const struct camss_format_info formats_rdi_845[] = {
>> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_SBGGR8_1X8, 8, V4L2_PIX_FMT_SBGGR8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SGBRG8_1X8, 8, V4L2_PIX_FMT_SGBRG8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SGRBG8_1X8, 8, V4L2_PIX_FMT_SGRBG8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SRGGB8_1X8, 8, V4L2_PIX_FMT_SRGGB8, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_SBGGR10_1X10, 10, V4L2_PIX_FMT_SBGGR10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SGBRG10_1X10, 10, V4L2_PIX_FMT_SGBRG10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SGRBG10_1X10, 10, V4L2_PIX_FMT_SGRBG10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SRGGB10_1X10, 10, V4L2_PIX_FMT_SRGGB10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_SBGGR10, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_SBGGR12_1X12, 12, V4L2_PIX_FMT_SBGGR12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SGBRG12_1X12, 12, V4L2_PIX_FMT_SGBRG12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SGRBG12_1X12, 12, V4L2_PIX_FMT_SGRBG12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SRGGB12_1X12, 12, V4L2_PIX_FMT_SRGGB12P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 12) },
>> + { MEDIA_BUS_FMT_SBGGR14_1X14, 14, V4L2_PIX_FMT_SBGGR14P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
>> + { MEDIA_BUS_FMT_SGBRG14_1X14, 14, V4L2_PIX_FMT_SGBRG14P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
>> + { MEDIA_BUS_FMT_SGRBG14_1X14, 14, V4L2_PIX_FMT_SGRBG14P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
>> + { MEDIA_BUS_FMT_SRGGB14_1X14, 14, V4L2_PIX_FMT_SRGGB14P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 14) },
>> + { MEDIA_BUS_FMT_Y8_1X8, 8, V4L2_PIX_FMT_GREY, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 8) },
>> + { MEDIA_BUS_FMT_Y10_1X10, 10, V4L2_PIX_FMT_Y10P, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 10) },
>> + { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16, V4L2_PIX_FMT_Y10, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> +};
>> +
>> +static const struct camss_format_info formats_pix_8x16[] = {
>> + { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> +};
>> +
>> +static const struct camss_format_info formats_pix_8x96[] = {
>> + { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV12, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_YUYV8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_YVYU8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_UYVY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_VYUY8_1_5X8, 8, V4L2_PIX_FMT_NV21, 1,
>> + PER_PLANE_DATA(0, 1, 1, 2, 3, 8) },
>> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV16, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_NV61, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 2, 8) },
>> + { MEDIA_BUS_FMT_UYVY8_1X16, 8, V4L2_PIX_FMT_UYVY, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_VYUY8_1X16, 8, V4L2_PIX_FMT_VYUY, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_YUYV8_1X16, 8, V4L2_PIX_FMT_YUYV, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> + { MEDIA_BUS_FMT_YVYU8_1X16, 8, V4L2_PIX_FMT_YVYU, 1,
>> + PER_PLANE_DATA(0, 1, 1, 1, 1, 16) },
>> +};
>> +
>> +const struct camss_formats vfe_formats_rdi_8x16 = {
>> + .nformats = ARRAY_SIZE(formats_rdi_8x16),
>> + .formats = formats_rdi_8x16
>> };
>> -static const struct vfe_format formats_rdi_8x16[] = {
>> - { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
>> - { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
>> - { MEDIA_BUS_FMT_Y10_1X10, 10 },
>> +const struct camss_formats vfe_formats_pix_8x16 = {
>> + .nformats = ARRAY_SIZE(formats_pix_8x16),
>> + .formats = formats_pix_8x16
>> };
>> -static const struct vfe_format formats_pix_8x16[] = {
>> - { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
>> +const struct camss_formats vfe_formats_rdi_8x96 = {
>> + .nformats = ARRAY_SIZE(formats_rdi_8x96),
>> + .formats = formats_rdi_8x96
>> };
>> -static const struct vfe_format formats_rdi_8x96[] = {
>> - { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
>> - { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16 },
>> - { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SBGGR14_1X14, 14 },
>> - { MEDIA_BUS_FMT_SGBRG14_1X14, 14 },
>> - { MEDIA_BUS_FMT_SGRBG14_1X14, 14 },
>> - { MEDIA_BUS_FMT_SRGGB14_1X14, 14 },
>> - { MEDIA_BUS_FMT_Y10_1X10, 10 },
>> - { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16 },
>> +const struct camss_formats vfe_formats_pix_8x96 = {
>> + .nformats = ARRAY_SIZE(formats_pix_8x96),
>> + .formats = formats_pix_8x96
>> };
>> -static const struct vfe_format formats_pix_8x96[] = {
>> - { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
>> +const struct camss_formats vfe_formats_rdi_845 = {
>> + .nformats = ARRAY_SIZE(formats_rdi_845),
>> + .formats = formats_rdi_845
>> };
>> -static const struct vfe_format formats_rdi_845[] = {
>> - { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
>> - { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
>> - { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
>> - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, 16 },
>> - { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
>> - { MEDIA_BUS_FMT_SBGGR14_1X14, 14 },
>> - { MEDIA_BUS_FMT_SGBRG14_1X14, 14 },
>> - { MEDIA_BUS_FMT_SGRBG14_1X14, 14 },
>> - { MEDIA_BUS_FMT_SRGGB14_1X14, 14 },
>> - { MEDIA_BUS_FMT_Y8_1X8, 8 },
>> - { MEDIA_BUS_FMT_Y10_1X10, 10 },
>> - { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, 16 },
>> +/* TODO: Replace with pix formats */
>> +const struct camss_formats vfe_formats_pix_845 = {
>> + .nformats = ARRAY_SIZE(formats_rdi_845),
>> + .formats = formats_rdi_845
>> };
>> /*
>> @@ -132,18 +286,18 @@ static const struct vfe_format formats_rdi_845[]
>> = {
>> *
>> * Return number of bits per pixel
>> */
>> -static u8 vfe_get_bpp(const struct vfe_format *formats,
>> +static u8 vfe_get_bpp(const struct camss_format_info *formats,
>> unsigned int nformats, u32 code)
>> {
>> unsigned int i;
>> for (i = 0; i < nformats; i++)
>> if (code == formats[i].code)
>> - return formats[i].bpp;
>> + return formats[i].mbus_bpp;
>> WARN(1, "Unknown format\n");
>> - return formats[0].bpp;
>> + return formats[0].mbus_bpp;
>> }
>> static u32 vfe_find_code(u32 *code, unsigned int n_code,
>> @@ -1495,32 +1649,12 @@ int msm_vfe_subdev_init(struct camss *camss,
>> struct vfe_device *vfe,
>> init_completion(&l->output.sof);
>> init_completion(&l->output.reg_update);
>> - switch (camss->res->version) {
>> - case CAMSS_8x16:
>> - if (i == VFE_LINE_PIX) {
>> - l->formats = formats_pix_8x16;
>> - l->nformats = ARRAY_SIZE(formats_pix_8x16);
>> - } else {
>> - l->formats = formats_rdi_8x16;
>> - l->nformats = ARRAY_SIZE(formats_rdi_8x16);
>> - }
>> - break;
>> - case CAMSS_8x96:
>> - case CAMSS_660:
>> - if (i == VFE_LINE_PIX) {
>> - l->formats = formats_pix_8x96;
>> - l->nformats = ARRAY_SIZE(formats_pix_8x96);
>> - } else {
>> - l->formats = formats_rdi_8x96;
>> - l->nformats = ARRAY_SIZE(formats_rdi_8x96);
>> - }
>> - break;
>> - case CAMSS_845:
>> - case CAMSS_8250:
>> - case CAMSS_8280XP:
>> - l->formats = formats_rdi_845;
>> - l->nformats = ARRAY_SIZE(formats_rdi_845);
>> - break;
>> + if (i == VFE_LINE_PIX) {
>> + l->nformats = res->vfe.formats_pix->nformats;
>> + l->formats = res->vfe.formats_pix->formats;
>> + } else {
>> + l->nformats = res->vfe.formats_rdi->nformats;
>> + l->formats = res->vfe.formats_rdi->formats;
>> }
>> }
>> @@ -1684,10 +1818,13 @@ int msm_vfe_register_entities(struct
>> vfe_device *vfe,
>> video_out->bpl_alignment = 16;
>> video_out->line_based = 1;
>> }
>> +
>> + video_out->nformats = vfe->line[i].nformats;
>> + video_out->formats = vfe->line[i].formats;
>> +
>> snprintf(name, ARRAY_SIZE(name), "%s%d_%s%d",
>> MSM_VFE_NAME, vfe->id, "video", i);
>> - ret = msm_video_register(video_out, v4l2_dev, name,
>> - i == VFE_LINE_PIX ? 1 : 0);
>> + ret = msm_video_register(video_out, v4l2_dev, name);
>> if (ret < 0) {
>> dev_err(dev, "Failed to register video node: %d\n",
>> ret);
>> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.h
>> b/drivers/media/platform/qcom/camss/camss-vfe.h
>> index 87fc159c48cc..10e2cc3c0b83 100644
>> --- a/drivers/media/platform/qcom/camss/camss-vfe.h
>> +++ b/drivers/media/platform/qcom/camss/camss-vfe.h
>> @@ -92,7 +92,7 @@ struct vfe_line {
>> struct v4l2_rect crop;
>> struct camss_video video_out;
>> struct vfe_output output;
>> - const struct vfe_format *formats;
>> + const struct camss_format_info *formats;
>> unsigned int nformats;
>> };
>> @@ -132,6 +132,8 @@ struct vfe_subdev_resources {
>> bool has_pd;
>> char *pd_name;
>> const struct vfe_hw_ops *hw_ops;
>> + const struct camss_formats *formats_rdi;
>> + const struct camss_formats *formats_pix;
>> };
>> struct vfe_device {
>> @@ -224,6 +226,13 @@ void vfe_pm_domain_off(struct vfe_device *vfe);
>> */
>> int vfe_pm_domain_on(struct vfe_device *vfe);
>> +extern const struct camss_formats vfe_formats_rdi_8x16;
>> +extern const struct camss_formats vfe_formats_pix_8x16;
>> +extern const struct camss_formats vfe_formats_rdi_8x96;
>> +extern const struct camss_formats vfe_formats_pix_8x96;
>> +extern const struct camss_formats vfe_formats_rdi_845;
>> +extern const struct camss_formats vfe_formats_pix_845;
>> +
>> extern const struct vfe_hw_ops vfe_ops_4_1;
>> extern const struct vfe_hw_ops vfe_ops_4_7;
>> extern const struct vfe_hw_ops vfe_ops_4_8;
>> diff --git a/drivers/media/platform/qcom/camss/camss-video.c
>> b/drivers/media/platform/qcom/camss/camss-video.c
>> index 54cd82f74115..cd13a432e291 100644
>> --- a/drivers/media/platform/qcom/camss/camss-video.c
>> +++ b/drivers/media/platform/qcom/camss/camss-video.c
>> @@ -24,244 +24,6 @@
>> #define CAMSS_FRAME_MAX_HEIGHT_RDI 8191
>> #define CAMSS_FRAME_MAX_HEIGHT_PIX 4096
>> -struct fract {
>> - u8 numerator;
>> - u8 denominator;
>> -};
>> -
>> -/*
>> - * struct camss_format_info - ISP media bus format information
>> - * @code: V4L2 media bus format code
>> - * @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 pixelformat;
>> - u8 planes;
>> - struct fract hsub[3];
>> - struct fract vsub[3];
>> - unsigned int bpp[3];
>> -};
>> -
>> -static const struct camss_format_info formats_rdi_8x16[] = {
>> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_PIX_FMT_SBGGR8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_PIX_FMT_SGBRG8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_PIX_FMT_SGRBG8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_PIX_FMT_SRGGB8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> -};
>> -
>> -static const struct camss_format_info formats_rdi_8x96[] = {
>> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_PIX_FMT_SBGGR8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_PIX_FMT_SGBRG8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_PIX_FMT_SGRBG8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_PIX_FMT_SRGGB8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_PIX_FMT_SBGGR10, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SBGGR14_1X14, V4L2_PIX_FMT_SBGGR14P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
>> - { MEDIA_BUS_FMT_SGBRG14_1X14, V4L2_PIX_FMT_SGBRG14P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
>> - { MEDIA_BUS_FMT_SGRBG14_1X14, V4L2_PIX_FMT_SGRBG14P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
>> - { MEDIA_BUS_FMT_SRGGB14_1X14, V4L2_PIX_FMT_SRGGB14P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
>> - { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, V4L2_PIX_FMT_Y10, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> -};
>> -
>> -static const struct camss_format_info formats_rdi_845[] = {
>> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_SBGGR8_1X8, V4L2_PIX_FMT_SBGGR8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SGBRG8_1X8, V4L2_PIX_FMT_SGBRG8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SGRBG8_1X8, V4L2_PIX_FMT_SGRBG8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SRGGB8_1X8, V4L2_PIX_FMT_SRGGB8, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_SBGGR10_1X10, V4L2_PIX_FMT_SBGGR10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SGBRG10_1X10, V4L2_PIX_FMT_SGBRG10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SGRBG10_1X10, V4L2_PIX_FMT_SGRBG10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SRGGB10_1X10, V4L2_PIX_FMT_SRGGB10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_PIX_FMT_SBGGR10, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_SBGGR12_1X12, V4L2_PIX_FMT_SBGGR12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SGBRG12_1X12, V4L2_PIX_FMT_SGBRG12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SGRBG12_1X12, V4L2_PIX_FMT_SGRBG12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SRGGB12_1X12, V4L2_PIX_FMT_SRGGB12P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 12 } },
>> - { MEDIA_BUS_FMT_SBGGR14_1X14, V4L2_PIX_FMT_SBGGR14P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
>> - { MEDIA_BUS_FMT_SGBRG14_1X14, V4L2_PIX_FMT_SGBRG14P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
>> - { MEDIA_BUS_FMT_SGRBG14_1X14, V4L2_PIX_FMT_SGRBG14P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
>> - { MEDIA_BUS_FMT_SRGGB14_1X14, V4L2_PIX_FMT_SRGGB14P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 14 } },
>> - { MEDIA_BUS_FMT_Y8_1X8, V4L2_PIX_FMT_GREY, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 8 } },
>> - { MEDIA_BUS_FMT_Y10_1X10, V4L2_PIX_FMT_Y10P, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 10 } },
>> - { MEDIA_BUS_FMT_Y10_2X8_PADHI_LE, V4L2_PIX_FMT_Y10, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> -};
>> -
>> -static const struct camss_format_info formats_pix_8x16[] = {
>> - { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV12, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV12, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV21, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV21, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV16, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV16, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV16, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV16, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV61, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV61, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV61, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV61, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> -};
>> -
>> -static const struct camss_format_info formats_pix_8x96[] = {
>> - { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV12, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV12, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV12, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV21, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV21, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_UYVY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_VYUY8_1_5X8, V4L2_PIX_FMT_NV21, 1,
>> - { { 1, 1 } }, { { 2, 3 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV16, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV16, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV16, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV16, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_NV61, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_NV61, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_NV61, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_NV61, 1,
>> - { { 1, 1 } }, { { 1, 2 } }, { 8 } },
>> - { MEDIA_BUS_FMT_UYVY8_1X16, V4L2_PIX_FMT_UYVY, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_VYUY8_1X16, V4L2_PIX_FMT_VYUY, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_YUYV8_1X16, V4L2_PIX_FMT_YUYV, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> - { MEDIA_BUS_FMT_YVYU8_1X16, V4L2_PIX_FMT_YVYU, 1,
>> - { { 1, 1 } }, { { 1, 1 } }, { 16 } },
>> -};
>> -
>> /*
>> -----------------------------------------------------------------------------
>> * Helper functions
>> */
>> @@ -968,8 +730,7 @@ static int msm_video_init_format(struct
>> camss_video *video)
>> * Return 0 on success or a negative error code otherwise
>> */
>> -int msm_video_register(struct camss_video *video, struct
>> v4l2_device *v4l2_dev,
>> - const char *name, int is_pix)
>> +int msm_video_register(struct camss_video *video, struct v4l2_device
>> *v4l2_dev, const char *name)
>
> Please wrap the line above.
>
>> {
>> struct media_pad *pad = &video->pad;
>> struct video_device *vdev;
>> @@ -1006,34 +767,6 @@ int msm_video_register(struct camss_video
>> *video, struct v4l2_device *v4l2_dev,
>> mutex_init(&video->lock);
>> - switch (video->camss->res->version) {
>> - case CAMSS_8x16:
>> - if (is_pix) {
>> - video->formats = formats_pix_8x16;
>> - video->nformats = ARRAY_SIZE(formats_pix_8x16);
>> - } else {
>> - video->formats = formats_rdi_8x16;
>> - video->nformats = ARRAY_SIZE(formats_rdi_8x16);
>> - }
>> - break;
>> - case CAMSS_8x96:
>> - case CAMSS_660:
>> - if (is_pix) {
>> - video->formats = formats_pix_8x96;
>> - video->nformats = ARRAY_SIZE(formats_pix_8x96);
>> - } else {
>> - video->formats = formats_rdi_8x96;
>> - video->nformats = ARRAY_SIZE(formats_rdi_8x96);
>> - }
>> - break;
>> - case CAMSS_845:
>> - case CAMSS_8250:
>> - case CAMSS_8280XP:
>> - video->formats = formats_rdi_845;
>> - video->nformats = ARRAY_SIZE(formats_rdi_845);
>> - break;
>> - }
>> -
>> ret = msm_video_init_format(video);
>> if (ret < 0) {
>> dev_err(v4l2_dev->dev, "Failed to init format: %d\n", ret);
>> diff --git a/drivers/media/platform/qcom/camss/camss-video.h
>> b/drivers/media/platform/qcom/camss/camss-video.h
>> index bdbae8424140..4f6c0821ead2 100644
>> --- a/drivers/media/platform/qcom/camss/camss-video.h
>> +++ b/drivers/media/platform/qcom/camss/camss-video.h
>> @@ -33,8 +33,6 @@ struct camss_video_ops {
>> enum vb2_buffer_state state);
>> };
>> -struct camss_format_info;
>> -
>> struct camss_video {
>> struct camss *camss;
>> struct vb2_queue vb2_q;
>> @@ -52,8 +50,7 @@ struct camss_video {
>> unsigned int nformats;
>> };
>> -int msm_video_register(struct camss_video *video, struct
>> v4l2_device *v4l2_dev,
>> - const char *name, int is_pix);
>> +int msm_video_register(struct camss_video *video, struct v4l2_device
>> *v4l2_dev, const char *name);
>
> Please wrap the line above.
Yes this should be fixed. Thanks for catching this.
~Gjorgji
>
>> void msm_video_unregister(struct camss_video *video);
>> diff --git a/drivers/media/platform/qcom/camss/camss.c
>> b/drivers/media/platform/qcom/camss/camss.c
>> index e4ae81dc9a15..f3242d2d9807 100644
>> --- a/drivers/media/platform/qcom/camss/camss.c
>> +++ b/drivers/media/platform/qcom/camss/camss.c
>> @@ -143,7 +143,9 @@ static const struct camss_subdev_resources
>> vfe_res_8x16[] = {
>> .type = CAMSS_SUBDEV_TYPE_VFE,
>> .vfe = {
>> .line_num = 3,
>> - .hw_ops = &vfe_ops_4_1
>> + .hw_ops = &vfe_ops_4_1,
>> + .formats_rdi = &vfe_formats_rdi_8x16,
>> + .formats_pix = &vfe_formats_pix_8x16
>> }
>> }
>> };
>> @@ -318,7 +320,9 @@ static const struct camss_subdev_resources
>> vfe_res_8x96[] = {
>> .vfe = {
>> .line_num = 3,
>> .has_pd = true,
>> - .hw_ops = &vfe_ops_4_7
>> + .hw_ops = &vfe_ops_4_7,
>> + .formats_rdi = &vfe_formats_rdi_8x96,
>> + .formats_pix = &vfe_formats_pix_8x96
>> }
>> },
>> @@ -342,7 +346,9 @@ static const struct camss_subdev_resources
>> vfe_res_8x96[] = {
>> .vfe = {
>> .line_num = 3,
>> .has_pd = true,
>> - .hw_ops = &vfe_ops_4_7
>> + .hw_ops = &vfe_ops_4_7,
>> + .formats_rdi = &vfe_formats_rdi_8x96,
>> + .formats_pix = &vfe_formats_pix_8x96
>> }
>> }
>> };
>> @@ -538,7 +544,9 @@ static const struct camss_subdev_resources
>> vfe_res_660[] = {
>> .vfe = {
>> .line_num = 3,
>> .has_pd = true,
>> - .hw_ops = &vfe_ops_4_8
>> + .hw_ops = &vfe_ops_4_8,
>> + .formats_rdi = &vfe_formats_rdi_8x96,
>> + .formats_pix = &vfe_formats_pix_8x96
>> }
>> },
>> @@ -565,7 +573,9 @@ static const struct camss_subdev_resources
>> vfe_res_660[] = {
>> .vfe = {
>> .line_num = 3,
>> .has_pd = true,
>> - .hw_ops = &vfe_ops_4_8
>> + .hw_ops = &vfe_ops_4_8,
>> + .formats_rdi = &vfe_formats_rdi_8x96,
>> + .formats_pix = &vfe_formats_pix_8x96
>> }
>> }
>> };
>> @@ -758,7 +768,9 @@ static const struct camss_subdev_resources
>> vfe_res_845[] = {
>> .vfe = {
>> .line_num = 4,
>> .has_pd = true,
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> @@ -784,7 +796,9 @@ static const struct camss_subdev_resources
>> vfe_res_845[] = {
>> .vfe = {
>> .line_num = 4,
>> .has_pd = true,
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> @@ -809,7 +823,9 @@ static const struct camss_subdev_resources
>> vfe_res_845[] = {
>> .vfe = {
>> .is_lite = true,
>> .line_num = 4,
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> }
>> };
>> @@ -985,7 +1001,9 @@ static const struct camss_subdev_resources
>> vfe_res_8250[] = {
>> .line_num = 3,
>> .has_pd = true,
>> .pd_name = "ife0",
>> - .hw_ops = &vfe_ops_480
>> + .hw_ops = &vfe_ops_480,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> /* VFE1 */
>> @@ -1010,7 +1028,9 @@ static const struct camss_subdev_resources
>> vfe_res_8250[] = {
>> .line_num = 3,
>> .has_pd = true,
>> .pd_name = "ife1",
>> - .hw_ops = &vfe_ops_480
>> + .hw_ops = &vfe_ops_480,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> /* VFE2 (lite) */
>> @@ -1033,7 +1053,9 @@ static const struct camss_subdev_resources
>> vfe_res_8250[] = {
>> .vfe = {
>> .is_lite = true,
>> .line_num = 4,
>> - .hw_ops = &vfe_ops_480
>> + .hw_ops = &vfe_ops_480,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> /* VFE3 (lite) */
>> @@ -1056,7 +1078,9 @@ static const struct camss_subdev_resources
>> vfe_res_8250[] = {
>> .vfe = {
>> .is_lite = true,
>> .line_num = 4,
>> - .hw_ops = &vfe_ops_480
>> + .hw_ops = &vfe_ops_480,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> };
>> @@ -1267,7 +1291,9 @@ static const struct camss_subdev_resources
>> vfe_res_sc8280xp[] = {
>> .vfe = {
>> .line_num = 4,
>> .pd_name = "ife0",
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> /* VFE1 */
>> @@ -1285,7 +1311,9 @@ static const struct camss_subdev_resources
>> vfe_res_sc8280xp[] = {
>> .vfe = {
>> .line_num = 4,
>> .pd_name = "ife1",
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> /* VFE2 */
>> @@ -1303,7 +1331,9 @@ static const struct camss_subdev_resources
>> vfe_res_sc8280xp[] = {
>> .vfe = {
>> .line_num = 4,
>> .pd_name = "ife2",
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> /* VFE3 */
>> @@ -1321,7 +1351,9 @@ static const struct camss_subdev_resources
>> vfe_res_sc8280xp[] = {
>> .vfe = {
>> .line_num = 4,
>> .pd_name = "ife3",
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> /* VFE_LITE_0 */
>> @@ -1338,7 +1370,9 @@ static const struct camss_subdev_resources
>> vfe_res_sc8280xp[] = {
>> .vfe = {
>> .is_lite = true,
>> .line_num = 4,
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> /* VFE_LITE_1 */
>> @@ -1355,7 +1389,9 @@ static const struct camss_subdev_resources
>> vfe_res_sc8280xp[] = {
>> .vfe = {
>> .is_lite = true,
>> .line_num = 4,
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> /* VFE_LITE_2 */
>> @@ -1372,7 +1408,9 @@ static const struct camss_subdev_resources
>> vfe_res_sc8280xp[] = {
>> .vfe = {
>> .is_lite = true,
>> .line_num = 4,
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> /* VFE_LITE_3 */
>> @@ -1389,7 +1427,9 @@ static const struct camss_subdev_resources
>> vfe_res_sc8280xp[] = {
>> .vfe = {
>> .is_lite = true,
>> .line_num = 4,
>> - .hw_ops = &vfe_ops_170
>> + .hw_ops = &vfe_ops_170,
>> + .formats_rdi = &vfe_formats_rdi_845,
>> + .formats_pix = &vfe_formats_pix_845
>> }
>> },
>> };
>> diff --git a/drivers/media/platform/qcom/camss/camss.h
>> b/drivers/media/platform/qcom/camss/camss.h
>> index 2477821dfd85..4b13012940bf 100644
>> --- a/drivers/media/platform/qcom/camss/camss.h
>> +++ b/drivers/media/platform/qcom/camss/camss.h
>> @@ -22,6 +22,7 @@
>> #include "camss-csiphy.h"
>> #include "camss-ispif.h"
>> #include "camss-vfe.h"
>> +#include "camss-format.h"
>> #define to_camss(ptr_module) \
>> container_of(ptr_module, struct camss, ptr_module)
>
> --
> Best wishes,
> Vladimir
On 4/11/24 15:45, Gjorgji Rosikopulos wrote:
> From: Radoslav Tsvetkov <[email protected]>
>
> Move out the format related helper functions from vfe and video in a
> separate file. The goal here is to create a format API.
>
> Signed-off-by: Radoslav Tsvetkov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
> drivers/media/platform/qcom/camss/Makefile | 1 +
> .../media/platform/qcom/camss/camss-format.c | 98 +++++++++++++++++++
> .../media/platform/qcom/camss/camss-format.h | 5 +
> drivers/media/platform/qcom/camss/camss-vfe.c | 86 +++++-----------
> .../media/platform/qcom/camss/camss-video.c | 26 +----
> 5 files changed, 128 insertions(+), 88 deletions(-)
> create mode 100644 drivers/media/platform/qcom/camss/camss-format.c
>
> diff --git a/drivers/media/platform/qcom/camss/Makefile b/drivers/media/platform/qcom/camss/Makefile
> index 0d4389ab312d..e636968a1126 100644
> --- a/drivers/media/platform/qcom/camss/Makefile
> +++ b/drivers/media/platform/qcom/camss/Makefile
> @@ -19,5 +19,6 @@ qcom-camss-objs += \
> camss-vfe-gen1.o \
> camss-vfe.o \
> camss-video.o \
> + camss-format.o \
>
> obj-$(CONFIG_VIDEO_QCOM_CAMSS) += qcom-camss.o
> diff --git a/drivers/media/platform/qcom/camss/camss-format.c b/drivers/media/platform/qcom/camss/camss-format.c
> new file mode 100644
> index 000000000000..6279cb099625
> --- /dev/null
> +++ b/drivers/media/platform/qcom/camss/camss-format.c
> @@ -0,0 +1,98 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Copyright (c) 2023, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2023 Qualcomm Technologies, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
SPDX-License-Identifier is fully sufficient, the licence description shall be removed.
> +
> +#include <linux/bug.h>
> +#include <linux/errno.h>
> +
> +#include "camss-format.h"
> +
> +/*
> + * camss_format_get_bpp - Map media bus format to bits per pixel
> + * @formats: supported media bus formats array
> + * @nformats: size of @formats array
> + * @code: media bus format code
> + *
> + * Return number of bits per pixel
> + */
> +u8 camss_format_get_bpp(const struct camss_format_info *formats, unsigned int nformats, u32 code)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < nformats; i++)
> + if (code == formats[i].code)
> + return formats[i].mbus_bpp;
> +
> + WARN(1, "Unknown format\n");
> +
> + return formats[0].mbus_bpp;
> +}
> +
> +/*
> + * camss_format_find_code - Find a format code in an array
> + * @code: a pointer to media bus format codes array
> + * @n_code: size of @code array
> + * @index: index of code in the array
> + * @req_code: required code
> + *
> + * Return media bus format code
> + */
> +u32 camss_format_find_code(u32 *code, unsigned int n_code, unsigned int index, u32 req_code)
> +{
> + int i;
> +
> + if (!req_code && index >= n_code)
> + return 0;
> +
0 as an error condition indicator is not very common, at least it shall be
documented in the comment.
> + for (i = 0; i < n_code; i++) {
> + if (req_code) {
> + if (req_code == code[i])
> + return req_code;
> + } else {
> + if (i == index)
> + return code[i];
> + }
> + }
> +
> + return code[0];
> +}
> +
> +/*
> + * camss_format_find_format - Find a format in an array
> + * @code: media bus format code
> + * @pixelformat: V4L2 pixel format FCC identifier
> + * @formats: a pointer to formats array
> + * @nformats: size of @formats array
> + *
> + * Return index of a format or a negative error code otherwise
> + */
> +int camss_format_find_format(u32 code, u32 pixelformat, const struct camss_format_info *formats,
> + unsigned int nformats)
> +{
> + int i;
unsigned int i
> +
> + for (i = 0; i < nformats; i++) {
> + if (formats[i].code == code &&
> + formats[i].pixelformat == pixelformat)
> + return i;
> + }
> +
> + for (i = 0; i < nformats; i++) {
> + if (formats[i].code == code)
> + return i;
> + }
> +
> + WARN_ON(1);
> +
WARN_ON() is not needed here, it has to be removed.
> + return -EINVAL;
> +}
> diff --git a/drivers/media/platform/qcom/camss/camss-format.h b/drivers/media/platform/qcom/camss/camss-format.h
> index bfbc761bd46c..86b5790e343d 100644
> --- a/drivers/media/platform/qcom/camss/camss-format.h
> +++ b/drivers/media/platform/qcom/camss/camss-format.h
> @@ -59,4 +59,9 @@ struct camss_formats {
> 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__ */
> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
> index 2d5a64c055f1..83c5a36d071f 100644
> --- a/drivers/media/platform/qcom/camss/camss-vfe.c
> +++ b/drivers/media/platform/qcom/camss/camss-vfe.c
> @@ -278,48 +278,6 @@ const struct camss_formats vfe_formats_pix_845 = {
> .formats = formats_rdi_845
> };
>
> -/*
> - * vfe_get_bpp - map media bus format to bits per pixel
> - * @formats: supported media bus formats array
> - * @nformats: size of @formats array
> - * @code: media bus format code
> - *
> - * Return number of bits per pixel
> - */
> -static u8 vfe_get_bpp(const struct camss_format_info *formats,
> - unsigned int nformats, u32 code)
> -{
> - unsigned int i;
> -
> - for (i = 0; i < nformats; i++)
> - if (code == formats[i].code)
> - return formats[i].mbus_bpp;
> -
> - WARN(1, "Unknown format\n");
> -
> - return formats[0].mbus_bpp;
> -}
> -
> -static u32 vfe_find_code(u32 *code, unsigned int n_code,
> - unsigned int index, u32 req_code)
> -{
> - int i;
> -
> - if (!req_code && (index >= n_code))
> - return 0;
> -
> - for (i = 0; i < n_code; i++)
> - if (req_code) {
> - if (req_code == code[i])
> - return req_code;
> - } else {
> - if (i == index)
> - return code[i];
> - }
> -
> - return code[0];
> -}
> -
> static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
> unsigned int index, u32 src_req_code)
> {
> @@ -335,8 +293,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
> MEDIA_BUS_FMT_YUYV8_1_5X8,
> };
>
> - return vfe_find_code(src_code, ARRAY_SIZE(src_code),
> - index, src_req_code);
> + return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
> + index, src_req_code);
> }
> case MEDIA_BUS_FMT_YVYU8_1X16:
> {
> @@ -345,8 +303,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
> MEDIA_BUS_FMT_YVYU8_1_5X8,
> };
>
> - return vfe_find_code(src_code, ARRAY_SIZE(src_code),
> - index, src_req_code);
> + return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
> + index, src_req_code);
> }
> case MEDIA_BUS_FMT_UYVY8_1X16:
> {
> @@ -355,8 +313,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
> MEDIA_BUS_FMT_UYVY8_1_5X8,
> };
>
> - return vfe_find_code(src_code, ARRAY_SIZE(src_code),
> - index, src_req_code);
> + return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
> + index, src_req_code);
> }
> case MEDIA_BUS_FMT_VYUY8_1X16:
> {
> @@ -365,8 +323,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
> MEDIA_BUS_FMT_VYUY8_1_5X8,
> };
>
> - return vfe_find_code(src_code, ARRAY_SIZE(src_code),
> - index, src_req_code);
> + return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
> + index, src_req_code);
> }
> default:
> if (index > 0)
> @@ -391,8 +349,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
> MEDIA_BUS_FMT_YUYV8_1_5X8,
> };
>
> - return vfe_find_code(src_code, ARRAY_SIZE(src_code),
> - index, src_req_code);
> + return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
> + index, src_req_code);
> }
> case MEDIA_BUS_FMT_YVYU8_1X16:
> {
> @@ -404,8 +362,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
> MEDIA_BUS_FMT_YVYU8_1_5X8,
> };
>
> - return vfe_find_code(src_code, ARRAY_SIZE(src_code),
> - index, src_req_code);
> + return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
> + index, src_req_code);
> }
> case MEDIA_BUS_FMT_UYVY8_1X16:
> {
> @@ -417,8 +375,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
> MEDIA_BUS_FMT_UYVY8_1_5X8,
> };
>
> - return vfe_find_code(src_code, ARRAY_SIZE(src_code),
> - index, src_req_code);
> + return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
> + index, src_req_code);
> }
> case MEDIA_BUS_FMT_VYUY8_1X16:
> {
> @@ -430,8 +388,8 @@ static u32 vfe_src_pad_code(struct vfe_line *line, u32 sink_code,
> MEDIA_BUS_FMT_VYUY8_1_5X8,
> };
>
> - return vfe_find_code(src_code, ARRAY_SIZE(src_code),
> - index, src_req_code);
> + return camss_format_find_code(src_code, ARRAY_SIZE(src_code),
> + index, src_req_code);
> }
> default:
> if (index > 0)
> @@ -714,9 +672,9 @@ static int vfe_set_clock_rates(struct vfe_device *vfe)
> } else {
> struct vfe_line *l = &vfe->line[j];
>
> - bpp = vfe_get_bpp(l->formats,
> - l->nformats,
> - l->fmt[MSM_VFE_PAD_SINK].code);
> + bpp = camss_format_get_bpp(l->formats,
> + l->nformats,
> + l->fmt[MSM_VFE_PAD_SINK].code);
> tmp = pixel_clock[j] * bpp / 64;
> }
>
> @@ -795,9 +753,9 @@ static int vfe_check_clock_rates(struct vfe_device *vfe)
> } else {
> struct vfe_line *l = &vfe->line[j];
>
> - bpp = vfe_get_bpp(l->formats,
> - l->nformats,
> - l->fmt[MSM_VFE_PAD_SINK].code);
> + bpp = camss_format_get_bpp(l->formats,
> + l->nformats,
> + l->fmt[MSM_VFE_PAD_SINK].code);
> tmp = pixel_clock[j] * bpp / 64;
> }
>
> diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
> index cd13a432e291..00b10dda3615 100644
> --- a/drivers/media/platform/qcom/camss/camss-video.c
> +++ b/drivers/media/platform/qcom/camss/camss-video.c
> @@ -28,27 +28,6 @@
> * Helper functions
> */
>
> -static int video_find_format(u32 code, u32 pixelformat,
> - const struct camss_format_info *formats,
> - unsigned int nformats)
> -{
> - int i;
> -
> - for (i = 0; i < nformats; i++) {
> - if (formats[i].code == code &&
> - formats[i].pixelformat == pixelformat)
> - return i;
> - }
> -
> - for (i = 0; i < nformats; i++)
> - if (formats[i].code == code)
> - return i;
> -
> - WARN_ON(1);
> -
> - return -EINVAL;
> -}
> -
> /*
> * video_mbus_to_pix_mp - Convert v4l2_mbus_framefmt to v4l2_pix_format_mplane
> * @mbus: v4l2_mbus_framefmt format (input)
> @@ -121,9 +100,8 @@ static int video_get_subdev_format(struct camss_video *video,
> if (ret)
> return ret;
>
> - ret = video_find_format(fmt.format.code,
> - format->fmt.pix_mp.pixelformat,
> - video->formats, video->nformats);
> + ret = camss_format_find_format(fmt.format.code, format->fmt.pix_mp.pixelformat,
> + video->formats, video->nformats);
> if (ret < 0)
> return ret;
>
--
Best wishes,
Vladimir
On 4/11/24 15:45, Gjorgji Rosikopulos wrote:
> From: Milen Mitkov <[email protected]>
>
> Decouple the direct calls to VFE's vfe_get/put in the CSID subdev
> in order to prepare for the introduction of IFE subdev.
>
> Also decouple CSID base address from VFE since on the Titan platform
> CSID register base address resides within VFE's base address.
>
> Signed-off-by: Milen Mitkov <[email protected]>
> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
> ---
> .../media/platform/qcom/camss/camss-csid.c | 16 +++--
> .../media/platform/qcom/camss/camss-csid.h | 1 +
> drivers/media/platform/qcom/camss/camss.c | 69 +++++++++++++++++++
> drivers/media/platform/qcom/camss/camss.h | 8 +++
> 4 files changed, 89 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
> index 5b23f5b8746d..858db5d4ca75 100644
> --- a/drivers/media/platform/qcom/camss/camss-csid.c
> +++ b/drivers/media/platform/qcom/camss/camss-csid.c
> @@ -602,7 +602,6 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
> struct csid_device *csid = v4l2_get_subdevdata(sd);
> struct camss *camss = csid->camss;
> struct device *dev = camss->dev;
> - struct vfe_device *vfe = &camss->vfe[csid->id];
> int ret = 0;
>
> if (on) {
> @@ -611,7 +610,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
> * switching on the CSID. Do so unconditionally, as there is no
> * drawback in following the same powering order on older SoCs.
> */
> - ret = vfe_get(vfe);
> + ret = csid->res->parent_dev_ops->get(camss, csid->id);
> if (ret < 0)
> return ret;
>
> @@ -663,7 +662,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
> regulator_bulk_disable(csid->num_supplies,
> csid->supplies);
> pm_runtime_put_sync(dev);
> - vfe_put(vfe);
> + csid->res->parent_dev_ops->put(camss, csid->id);
> }
>
> return ret;
> @@ -1021,6 +1020,11 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
> csid->id = id;
> csid->res = &res->csid;
>
> + if (dev_WARN_ONCE(dev, !csid->res->parent_dev_ops,
Please remove/replace dev_WARN_ONCE() to a lesser dev_warn_once(), wherever it's
possible please do not use/introduce WARN() type of writes to the kernel log buffer...
> + "Error: CSID depends on VFE/IFE device ops!\n")) {
> + return -EINVAL;
> + }
> +
> csid->res->hw_ops->subdev_init(csid);
>
> /* Memory */
> @@ -1031,9 +1035,11 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
> * VFE to be initialized before CSID
> */
> if (id >= 2) /* VFE/CSID lite */
> - csid->base = camss->vfe[id].base + VFE_480_LITE_CSID_OFFSET;
> + csid->base = csid->res->parent_dev_ops->get_base_address(camss, id)
> + + VFE_480_LITE_CSID_OFFSET;
> else
> - csid->base = camss->vfe[id].base + VFE_480_CSID_OFFSET;
> + csid->base = csid->res->parent_dev_ops->get_base_address(camss, id)
> + + VFE_480_CSID_OFFSET;
> } else {
> csid->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]);
> if (IS_ERR(csid->base))
> diff --git a/drivers/media/platform/qcom/camss/camss-csid.h b/drivers/media/platform/qcom/camss/camss-csid.h
> index 0e385d17c250..8cdae98e4dca 100644
> --- a/drivers/media/platform/qcom/camss/camss-csid.h
> +++ b/drivers/media/platform/qcom/camss/camss-csid.h
> @@ -157,6 +157,7 @@ struct csid_hw_ops {
> struct csid_subdev_resources {
> bool is_lite;
> const struct csid_hw_ops *hw_ops;
> + const struct parent_dev_ops *parent_dev_ops;
> const struct csid_formats *formats;
> };
>
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index 37060eaa0ba5..4d625ef59cf7 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -32,6 +32,8 @@
> #define CAMSS_CLOCK_MARGIN_NUMERATOR 105
> #define CAMSS_CLOCK_MARGIN_DENOMINATOR 100
>
> +static const struct parent_dev_ops vfe_parent_dev_ops;
> +
> static const struct camss_subdev_resources csiphy_res_8x16[] = {
> /* CSIPHY0 */
> {
> @@ -87,6 +89,7 @@ static const struct camss_subdev_resources csid_res_8x16[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_4_1,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_4_1
> }
> },
> @@ -109,6 +112,7 @@ static const struct camss_subdev_resources csid_res_8x16[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_4_1,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_4_1
> }
> },
> @@ -226,6 +230,7 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_4_7,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_4_7
> }
> },
> @@ -248,6 +253,7 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_4_7,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_4_7
> }
> },
> @@ -270,6 +276,7 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_4_7,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_4_7
> }
> },
> @@ -292,6 +299,7 @@ static const struct camss_subdev_resources csid_res_8x96[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_4_7,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_4_7
> }
> }
> @@ -445,6 +453,7 @@ static const struct camss_subdev_resources csid_res_660[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_4_7,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_4_7
> }
> },
> @@ -470,6 +479,7 @@ static const struct camss_subdev_resources csid_res_660[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_4_7,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_4_7
> }
> },
> @@ -495,6 +505,7 @@ static const struct camss_subdev_resources csid_res_660[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_4_7,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_4_7
> }
> },
> @@ -520,6 +531,7 @@ static const struct camss_subdev_resources csid_res_660[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_4_7,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_4_7
> }
> }
> @@ -714,6 +726,7 @@ static const struct camss_subdev_resources csid_res_845[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -739,6 +752,7 @@ static const struct camss_subdev_resources csid_res_845[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -765,6 +779,7 @@ static const struct camss_subdev_resources csid_res_845[] = {
> .csid = {
> .is_lite = true,
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> }
> @@ -957,6 +972,7 @@ static const struct camss_subdev_resources csid_res_8250[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -974,6 +990,7 @@ static const struct camss_subdev_resources csid_res_8250[] = {
> .type = CAMSS_SUBDEV_TYPE_CSID,
> .csid = {
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -991,6 +1008,7 @@ static const struct camss_subdev_resources csid_res_8250[] = {
> .csid = {
> .is_lite = true,
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -1008,6 +1026,7 @@ static const struct camss_subdev_resources csid_res_8250[] = {
> .csid = {
> .is_lite = true,
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> }
> @@ -1212,6 +1231,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
> .interrupt = { "csid0" },
> .csid = {
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -1227,6 +1247,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
> .interrupt = { "csid1" },
> .csid = {
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -1242,6 +1263,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
> .interrupt = { "csid2" },
> .csid = {
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -1257,6 +1279,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
> .interrupt = { "csid3" },
> .csid = {
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -1272,6 +1295,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
> .csid = {
> .is_lite = true,
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -1287,6 +1311,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
> .csid = {
> .is_lite = true,
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -1302,6 +1327,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
> .csid = {
> .is_lite = true,
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> },
> @@ -1317,6 +1343,7 @@ static const struct camss_subdev_resources csid_res_sc8280xp[] = {
> .csid = {
> .is_lite = true,
> .hw_ops = &csid_ops_gen2,
> + .parent_dev_ops = &vfe_parent_dev_ops,
> .formats = &csid_formats_gen2
> }
> }
> @@ -1661,6 +1688,48 @@ void camss_pm_domain_off(struct camss *camss, int id)
> }
> }
>
> +static int vfe_parent_dev_ops_get(struct camss *camss, int id)
> +{
> + int ret = -EINVAL;
> +
> + if (id < camss->res->vfe_num) {
if (id >= camss->res->vfe_num)
return -EINVAL;
> + struct vfe_device *vfe = &camss->vfe[id];
> +
> + ret = vfe_get(vfe);
> + }
> +
> + return ret;
> +}
> +
> +static int vfe_parent_dev_ops_put(struct camss *camss, int id)
> +{
> + if (id < camss->res->vfe_num) {
> + struct vfe_device *vfe = &camss->vfe[id];
> +
> + vfe_put(vfe);
> + }
> +
> + return 0;
> +}
> +
> +static void __iomem
> +*vfe_parent_dev_ops_get_base_address(struct camss *camss, int id)
> +{
> + if (id < camss->res->vfe_num) {
> + struct vfe_device *vfe = &camss->vfe[id];
> +
> + return vfe->base;
> + }
> +
> + return NULL;
I can find code snippets above like
if (IS_ERR(csid->base))
...
So, is it really a good idea to return NULL on error? Probably it might be better
to return a reasonable error to the caller.
> +}
> +
> +static const struct parent_dev_ops vfe_parent_dev_ops = {
> + .get = vfe_parent_dev_ops_get,
> + .put = vfe_parent_dev_ops_put,
> + .get_base_address = vfe_parent_dev_ops_get_base_address
> +};
> +
> /*
> * camss_of_parse_endpoint_node - Parse port endpoint node
> * @dev: Device
> diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h
> index a5be9e872992..b3c967bcf8a9 100644
> --- a/drivers/media/platform/qcom/camss/camss.h
> +++ b/drivers/media/platform/qcom/camss/camss.h
> @@ -143,6 +143,12 @@ struct camss_clock {
> u32 nfreqs;
> };
>
> +struct parent_dev_ops {
> + int (*get)(struct camss *camss, int id);
> + int (*put)(struct camss *camss, int id);
> + void __iomem *(*get_base_address)(struct camss *camss, int id);
> +};
> +
> void camss_add_clock_margin(u64 *rate);
> int camss_enable_clocks(int nclocks, struct camss_clock *clock,
> struct device *dev);
> @@ -153,6 +159,8 @@ s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp,
> int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock);
> int camss_pm_domain_on(struct camss *camss, int id);
> void camss_pm_domain_off(struct camss *camss, int id);
> +int camss_vfe_get(struct camss *camss, int id);
> +void camss_vfe_put(struct camss *camss, int id);
> void camss_delete(struct camss *camss);
>
> #endif /* QC_MSM_CAMSS_H */
--
Best wishes,
Vladimir
Hi Vladimir,
Thanks for the review,
On 5/13/2024 6:58 PM, Vladimir Zapolskiy wrote:
> On 4/11/24 15:45, Gjorgji Rosikopulos wrote:
>> From: Milen Mitkov <[email protected]>
>>
>> Decouple the direct calls to VFE's vfe_get/put in the CSID subdev
>> in order to prepare for the introduction of IFE subdev.
>>
>> Also decouple CSID base address from VFE since on the Titan platform
>> CSID register base address resides within VFE's base address.
>>
>> Signed-off-by: Milen Mitkov <[email protected]>
>> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
>> ---
>> .../media/platform/qcom/camss/camss-csid.c | 16 +++--
>> .../media/platform/qcom/camss/camss-csid.h | 1 +
>> drivers/media/platform/qcom/camss/camss.c | 69 +++++++++++++++++++
>> drivers/media/platform/qcom/camss/camss.h | 8 +++
>> 4 files changed, 89 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/camss/camss-csid.c
>> b/drivers/media/platform/qcom/camss/camss-csid.c
>> index 5b23f5b8746d..858db5d4ca75 100644
>> --- a/drivers/media/platform/qcom/camss/camss-csid.c
>> +++ b/drivers/media/platform/qcom/camss/camss-csid.c
>> @@ -602,7 +602,6 @@ static int csid_set_power(struct v4l2_subdev *sd,
>> int on)
>> struct csid_device *csid = v4l2_get_subdevdata(sd);
>> struct camss *camss = csid->camss;
>> struct device *dev = camss->dev;
>> - struct vfe_device *vfe = &camss->vfe[csid->id];
>> int ret = 0;
>> if (on) {
>> @@ -611,7 +610,7 @@ static int csid_set_power(struct v4l2_subdev *sd,
>> int on)
>> * switching on the CSID. Do so unconditionally, as there is no
>> * drawback in following the same powering order on older SoCs.
>> */
>> - ret = vfe_get(vfe);
>> + ret = csid->res->parent_dev_ops->get(camss, csid->id);
>> if (ret < 0)
>> return ret;
>> @@ -663,7 +662,7 @@ static int csid_set_power(struct v4l2_subdev
>> *sd, int on)
>> regulator_bulk_disable(csid->num_supplies,
>> csid->supplies);
>> pm_runtime_put_sync(dev);
>> - vfe_put(vfe);
>> + csid->res->parent_dev_ops->put(camss, csid->id);
>> }
>> return ret;
>> @@ -1021,6 +1020,11 @@ int msm_csid_subdev_init(struct camss *camss,
>> struct csid_device *csid,
>> csid->id = id;
>> csid->res = &res->csid;
>> + if (dev_WARN_ONCE(dev, !csid->res->parent_dev_ops,
>
> Please remove/replace dev_WARN_ONCE() to a lesser dev_warn_once(),
> wherever it's
> possible please do not use/introduce WARN() type of writes to the kernel
> log buffer...
The error is fatal and driver probe will fail if this happens,
it is good to have it in kernel log buffer.
However i agree it can be changed to dev_warn_once.
>
>> + "Error: CSID depends on VFE/IFE device ops!\n")) {
>> + return -EINVAL;
>> + }
>> +
>> csid->res->hw_ops->subdev_init(csid);
>> /* Memory */
>> @@ -1031,9 +1035,11 @@ int msm_csid_subdev_init(struct camss *camss,
>> struct csid_device *csid,
>> * VFE to be initialized before CSID
>> */
>> if (id >= 2) /* VFE/CSID lite */
>> - csid->base = camss->vfe[id].base + VFE_480_LITE_CSID_OFFSET;
>> + csid->base =
>> csid->res->parent_dev_ops->get_base_address(camss, id)
>> + + VFE_480_LITE_CSID_OFFSET;
>> else
>> - csid->base = camss->vfe[id].base + VFE_480_CSID_OFFSET;
>> + csid->base =
>> csid->res->parent_dev_ops->get_base_address(camss, id)
>> + + VFE_480_CSID_OFFSET;
>> } else {
>> csid->base = devm_platform_ioremap_resource_byname(pdev,
>> res->reg[0]);
>> if (IS_ERR(csid->base))
>> diff --git a/drivers/media/platform/qcom/camss/camss-csid.h
>> b/drivers/media/platform/qcom/camss/camss-csid.h
>> index 0e385d17c250..8cdae98e4dca 100644
>> --- a/drivers/media/platform/qcom/camss/camss-csid.h
>> +++ b/drivers/media/platform/qcom/camss/camss-csid.h
>> @@ -157,6 +157,7 @@ struct csid_hw_ops {
>> struct csid_subdev_resources {
>> bool is_lite;
>> const struct csid_hw_ops *hw_ops;
>> + const struct parent_dev_ops *parent_dev_ops;
>> const struct csid_formats *formats;
>> };
>> diff --git a/drivers/media/platform/qcom/camss/camss.c
>> b/drivers/media/platform/qcom/camss/camss.c
>> index 37060eaa0ba5..4d625ef59cf7 100644
>> --- a/drivers/media/platform/qcom/camss/camss.c
>> +++ b/drivers/media/platform/qcom/camss/camss.c
>> @@ -32,6 +32,8 @@
>> #define CAMSS_CLOCK_MARGIN_NUMERATOR 105
>> #define CAMSS_CLOCK_MARGIN_DENOMINATOR 100
>> +static const struct parent_dev_ops vfe_parent_dev_ops;
>> +
>> static const struct camss_subdev_resources csiphy_res_8x16[] = {
>> /* CSIPHY0 */
>> {
>> @@ -87,6 +89,7 @@ static const struct camss_subdev_resources
>> csid_res_8x16[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_4_1,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_4_1
>> }
>> },
>> @@ -109,6 +112,7 @@ static const struct camss_subdev_resources
>> csid_res_8x16[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_4_1,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_4_1
>> }
>> },
>> @@ -226,6 +230,7 @@ static const struct camss_subdev_resources
>> csid_res_8x96[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_4_7,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_4_7
>> }
>> },
>> @@ -248,6 +253,7 @@ static const struct camss_subdev_resources
>> csid_res_8x96[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_4_7,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_4_7
>> }
>> },
>> @@ -270,6 +276,7 @@ static const struct camss_subdev_resources
>> csid_res_8x96[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_4_7,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_4_7
>> }
>> },
>> @@ -292,6 +299,7 @@ static const struct camss_subdev_resources
>> csid_res_8x96[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_4_7,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_4_7
>> }
>> }
>> @@ -445,6 +453,7 @@ static const struct camss_subdev_resources
>> csid_res_660[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_4_7,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_4_7
>> }
>> },
>> @@ -470,6 +479,7 @@ static const struct camss_subdev_resources
>> csid_res_660[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_4_7,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_4_7
>> }
>> },
>> @@ -495,6 +505,7 @@ static const struct camss_subdev_resources
>> csid_res_660[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_4_7,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_4_7
>> }
>> },
>> @@ -520,6 +531,7 @@ static const struct camss_subdev_resources
>> csid_res_660[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_4_7,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_4_7
>> }
>> }
>> @@ -714,6 +726,7 @@ static const struct camss_subdev_resources
>> csid_res_845[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -739,6 +752,7 @@ static const struct camss_subdev_resources
>> csid_res_845[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -765,6 +779,7 @@ static const struct camss_subdev_resources
>> csid_res_845[] = {
>> .csid = {
>> .is_lite = true,
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> }
>> @@ -957,6 +972,7 @@ static const struct camss_subdev_resources
>> csid_res_8250[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -974,6 +990,7 @@ static const struct camss_subdev_resources
>> csid_res_8250[] = {
>> .type = CAMSS_SUBDEV_TYPE_CSID,
>> .csid = {
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -991,6 +1008,7 @@ static const struct camss_subdev_resources
>> csid_res_8250[] = {
>> .csid = {
>> .is_lite = true,
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -1008,6 +1026,7 @@ static const struct camss_subdev_resources
>> csid_res_8250[] = {
>> .csid = {
>> .is_lite = true,
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> }
>> @@ -1212,6 +1231,7 @@ static const struct camss_subdev_resources
>> csid_res_sc8280xp[] = {
>> .interrupt = { "csid0" },
>> .csid = {
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -1227,6 +1247,7 @@ static const struct camss_subdev_resources
>> csid_res_sc8280xp[] = {
>> .interrupt = { "csid1" },
>> .csid = {
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -1242,6 +1263,7 @@ static const struct camss_subdev_resources
>> csid_res_sc8280xp[] = {
>> .interrupt = { "csid2" },
>> .csid = {
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -1257,6 +1279,7 @@ static const struct camss_subdev_resources
>> csid_res_sc8280xp[] = {
>> .interrupt = { "csid3" },
>> .csid = {
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -1272,6 +1295,7 @@ static const struct camss_subdev_resources
>> csid_res_sc8280xp[] = {
>> .csid = {
>> .is_lite = true,
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -1287,6 +1311,7 @@ static const struct camss_subdev_resources
>> csid_res_sc8280xp[] = {
>> .csid = {
>> .is_lite = true,
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -1302,6 +1327,7 @@ static const struct camss_subdev_resources
>> csid_res_sc8280xp[] = {
>> .csid = {
>> .is_lite = true,
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> },
>> @@ -1317,6 +1343,7 @@ static const struct camss_subdev_resources
>> csid_res_sc8280xp[] = {
>> .csid = {
>> .is_lite = true,
>> .hw_ops = &csid_ops_gen2,
>> + .parent_dev_ops = &vfe_parent_dev_ops,
>> .formats = &csid_formats_gen2
>> }
>> }
>> @@ -1661,6 +1688,48 @@ void camss_pm_domain_off(struct camss *camss,
>> int id)
>> }
>> }
>> +static int vfe_parent_dev_ops_get(struct camss *camss, int id)
>> +{
>> + int ret = -EINVAL;
>> +
>> + if (id < camss->res->vfe_num) {
>
>
> if (id >= camss->res->vfe_num)
> return -EINVAL;
:-). I believe this is metter of personal taste. I also like
the code which you have posted. But with function of this size
i dont see that it will make any difference.
>
>> + struct vfe_device *vfe = &camss->vfe[id];
>> +
>> + ret = vfe_get(vfe);
>> + }
>> +
>> + return ret;
>> +}
>> +
>> +static int vfe_parent_dev_ops_put(struct camss *camss, int id)
>> +{
>> + if (id < camss->res->vfe_num) {
>> + struct vfe_device *vfe = &camss->vfe[id];
>> +
>> + vfe_put(vfe);
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static void __iomem
>> +*vfe_parent_dev_ops_get_base_address(struct camss *camss, int id)
>> +{
>> + if (id < camss->res->vfe_num) {
>> + struct vfe_device *vfe = &camss->vfe[id];
>> +
>> + return vfe->base;
>> + }
>> +
>> + return NULL;
>
> I can find code snippets above like
>
> if (IS_ERR(csid->base))
> ...
>
> So, is it really a good idea to return NULL on error? Probably it might
> be better
> to return a reasonable error to the caller.
As general rule i agree. But here either we have address or not,
i dont see the reason to return an error code. Also i dont see what
caller will do if he gets error code instead of NULL.
I am refering in particular this case. If we have different error paths
of failiure maybe it will more sense.
>
>> +}
>> +
>> +static const struct parent_dev_ops vfe_parent_dev_ops = {
>> + .get = vfe_parent_dev_ops_get,
>> + .put = vfe_parent_dev_ops_put,
>> + .get_base_address = vfe_parent_dev_ops_get_base_address
>> +};
>> +
>> /*
>> * camss_of_parse_endpoint_node - Parse port endpoint node
>> * @dev: Device
>> diff --git a/drivers/media/platform/qcom/camss/camss.h
>> b/drivers/media/platform/qcom/camss/camss.h
>> index a5be9e872992..b3c967bcf8a9 100644
>> --- a/drivers/media/platform/qcom/camss/camss.h
>> +++ b/drivers/media/platform/qcom/camss/camss.h
>> @@ -143,6 +143,12 @@ struct camss_clock {
>> u32 nfreqs;
>> };
>> +struct parent_dev_ops {
>> + int (*get)(struct camss *camss, int id);
>> + int (*put)(struct camss *camss, int id);
>> + void __iomem *(*get_base_address)(struct camss *camss, int id);
>> +};
>> +
>> void camss_add_clock_margin(u64 *rate);
>> int camss_enable_clocks(int nclocks, struct camss_clock *clock,
>> struct device *dev);
>> @@ -153,6 +159,8 @@ s64 camss_get_link_freq(struct media_entity
>> *entity, unsigned int bpp,
>> int camss_get_pixel_clock(struct media_entity *entity, u64
>> *pixel_clock);
>> int camss_pm_domain_on(struct camss *camss, int id);
>> void camss_pm_domain_off(struct camss *camss, int id);
>> +int camss_vfe_get(struct camss *camss, int id);
>> +void camss_vfe_put(struct camss *camss, int id);
>> void camss_delete(struct camss *camss);
>> #endif /* QC_MSM_CAMSS_H */
>
> --
> Best wishes,
> Vladimir
Hi Vladimir,
Thanks for the review,
On 5/13/2024 6:39 PM, Vladimir Zapolskiy wrote:
> On 4/11/24 15:45, Gjorgji Rosikopulos wrote:
>> From: Radoslav Tsvetkov <[email protected]>
>>
>> Move out the format related helper functions from vfe and video in a
>> separate file. The goal here is to create a format API.
>>
>> Signed-off-by: Radoslav Tsvetkov <[email protected]>
>> Signed-off-by: Gjorgji Rosikopulos <[email protected]>
>> ---
>> drivers/media/platform/qcom/camss/Makefile | 1 +
>> .../media/platform/qcom/camss/camss-format.c | 98 +++++++++++++++++++
>> .../media/platform/qcom/camss/camss-format.h | 5 +
>> drivers/media/platform/qcom/camss/camss-vfe.c | 86 +++++-----------
>> .../media/platform/qcom/camss/camss-video.c | 26 +----
>> 5 files changed, 128 insertions(+), 88 deletions(-)
>> create mode 100644 drivers/media/platform/qcom/camss/camss-format.c
>>
>> diff --git a/drivers/media/platform/qcom/camss/Makefile
>> b/drivers/media/platform/qcom/camss/Makefile
>> index 0d4389ab312d..e636968a1126 100644
>> --- a/drivers/media/platform/qcom/camss/Makefile
>> +++ b/drivers/media/platform/qcom/camss/Makefile
>> @@ -19,5 +19,6 @@ qcom-camss-objs += \
>> camss-vfe-gen1.o \
>> camss-vfe.o \
>> camss-video.o \
>> + camss-format.o \
>> obj-$(CONFIG_VIDEO_QCOM_CAMSS) += qcom-camss.o
>> diff --git a/drivers/media/platform/qcom/camss/camss-format.c
>> b/drivers/media/platform/qcom/camss/camss-format.c
>> new file mode 100644
>> index 000000000000..6279cb099625
>> --- /dev/null
>> +++ b/drivers/media/platform/qcom/camss/camss-format.c
>> @@ -0,0 +1,98 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/* Copyright (c) 2023, The Linux Foundation. All rights reserved.
>> + * Copyright (c) 2023 Qualcomm Technologies, Inc.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 and
>> + * only version 2 as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + */
>
> SPDX-License-Identifier is fully sufficient, the licence description
> shall be removed.
I need to check, but as i can see with other files the license
description can be removed.
>
>> +
>> +#include <linux/bug.h>
>> +#include <linux/errno.h>
>> +
>> +#include "camss-format.h"
>> +
>> +/*
>> + * camss_format_get_bpp - Map media bus format to bits per pixel
>> + * @formats: supported media bus formats array
>> + * @nformats: size of @formats array
>> + * @code: media bus format code
>> + *
>> + * Return number of bits per pixel
>> + */
>> +u8 camss_format_get_bpp(const struct camss_format_info *formats,
>> unsigned int nformats, u32 code)
>> +{
>> + unsigned int i;
>> +
>> + for (i = 0; i < nformats; i++)
>> + if (code == formats[i].code)
>> + return formats[i].mbus_bpp;
>> +
>> + WARN(1, "Unknown format\n");
>> +
>> + return formats[0].mbus_bpp;
>> +}
>> +
>> +/*
>> + * camss_format_find_code - Find a format code in an array
>> + * @code: a pointer to media bus format codes array
>> + * @n_code: size of @code array
>> + * @index: index of code in the array
>> + * @req_code: required code
>> + *
>> + * Return media bus format code
>> + */
>> +u32 camss_format_find_code(u32 *code, unsigned int n_code, unsigned
>> int index, u32 req_code)
>> +{
>> + int i;
>> +
>> + if (!req_code && index >= n_code)
>> + return 0;
>> +
>
> 0 as an error condition indicator is not very common, at least it shall be
> documented in the comment.
The original function was vfe_find_code. This change moves all format
related functions across the sub-device files to camss-format
I believe that 0 is default format.
>
>> + for (i = 0; i < n_code; i++) {
>> + if (req_code) {
>> + if (req_code == code[i])
>> + return req_code;
>> + } else {
>> + if (i == index)
>> + return code[i];
>> + }
>> + }
>> +
>> + return code[0];
>> +}
>> +
>> +/*
>> + * camss_format_find_format - Find a format in an array
>> + * @code: media bus format code
>> + * @pixelformat: V4L2 pixel format FCC identifier
>> + * @formats: a pointer to formats array
>> + * @nformats: size of @formats array
>> + *
>> + * Return index of a format or a negative error code otherwise
>> + */
>> +int camss_format_find_format(u32 code, u32 pixelformat, const struct
>> camss_format_info *formats,
>> + unsigned int nformats)
>> +{
>> + int i;
>
> unsigned int i
Maybe it makes sense to go to all functions already existing in camss
and change int with unsigned int for for loops...
>
>> +
>> + for (i = 0; i < nformats; i++) {
>> + if (formats[i].code == code &&
>> + formats[i].pixelformat == pixelformat)
>> + return i;
>> + }
>> +
>> + for (i = 0; i < nformats; i++) {
>> + if (formats[i].code == code)
>> + return i;
>> + }
>> +
>> + WARN_ON(1);
>> +
>
> WARN_ON() is not needed here, it has to be removed.
Again this is migrated code from camss-video :/. I guess we need bigger
consensus to remove this WARN_ON. For me it makes sense to be removed.
~Gjorgji
On 13/05/2024 16:35, Gjorgji Rosikopulos (Consultant) wrote:
> I agree but i would propose to have next series for cleanup up patches,
> Otherwise we will have to many changes across the files.
So, I missed these plats in the code, thanks for spotting.
I'd like to get the header SPDX and style stuff Vlad highlighted fixed
in a V4 of this series.
However given the amount of effort required to verify these changes, I'd
rather avoid data-structure and/or logic changes at this stage.
---
bod
On 13/05/2024 17:52, Gjorgji Rosikopulos (Consultant) wrote:
>> 0 as an error condition indicator is not very common, at least it shall be
>> documented in the comment.
> The original function was vfe_find_code. This change moves all format
> related functions across the sub-device files to camss-format
> I believe that 0 is default format
For this series changing the result code is extraneous, agree.
We can debate such a change in a standalone patch on its own merits.
---
bod
On 13/05/2024 17:26, Gjorgji Rosikopulos (Consultant) wrote:
>>> +static void __iomem
>>> +*vfe_parent_dev_ops_get_base_address(struct camss *camss, int id)
>>> +{
>>> + if (id < camss->res->vfe_num) {
>>> + struct vfe_device *vfe = &camss->vfe[id];
>>> +
>>> + return vfe->base;
>>> + }
>>> +
>>> + return NULL;
>> I can find code snippets above like
>>
>> if (IS_ERR(csid->base))
>> ...
>>
>> So, is it really a good idea to return NULL on error? Probably it might
>> be better
>> to return a reasonable error to the caller.
> As general rule i agree. But here either we have address or not,
> i dont see the reason to return an error code. Also i dont see what
> caller will do if he gets error code instead of NULL.
> I am refering in particular this case. If we have different error paths
> of failiure maybe it will more sense.
I don't see a compelling reason to change the submitted code. I'd leave
well-enough alone for v4.
Please keep changes for V4 restricted to formatting/line indentation/SPDX.
I don't want to have to reverify all of this code unless a bug is found.
---
bod
On 5/13/2024 8:36 PM, Bryan O'Donoghue wrote:
> On 13/05/2024 16:35, Gjorgji Rosikopulos (Consultant) wrote:
>> I agree but i would propose to have next series for cleanup up patches,
>> Otherwise we will have to many changes across the files.
>
> So, I missed these plats in the code, thanks for spotting.
>
> I'd like to get the header SPDX and style stuff Vlad highlighted fixed
> in a V4 of this series.
>
> However given the amount of effort required to verify these changes, I'd
> rather avoid data-structure and/or logic changes at this stage.
I agree. V4 will contain only style stuff from Vlad and patch 3.1 with
fix for csyphy type.
~Gjorgji
>
> ---
> bod