Commit 6c46cb0d authored by Radoslav Tsvetkov's avatar Radoslav Tsvetkov Committed by Hans Verkuil

media: qcom: camss: Attach formats to VFE resources

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: default avatarRadoslav Tsvetkov <quic_rtsvetko@quicinc.com>
Signed-off-by: default avatarGjorgji Rosikopulos <quic_grosikop@quicinc.com>
Acked-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent ae44829a
/* SPDX-License-Identifier: GPL-2.0 */
/*
* camss-format.h
*
* Qualcomm MSM Camera Subsystem - Format helpers
*
* Copyright (c) 2023, The Linux Foundation. All rights reserved.
* Copyright (c) 2023 Qualcomm Technologies, Inc.
*/
#ifndef __CAMSS_FORMAT_H__
#define __CAMSS_FORMAT_H__
#include <linux/types.h>
#define PER_PLANE_DATA(plane, h_fract_num, h_fract_den, v_fract_num, v_fract_den, _bpp) \
.hsub[(plane)].numerator = (h_fract_num), \
.hsub[(plane)].denominator = (h_fract_den), \
.vsub[(plane)].numerator = (v_fract_num), \
.vsub[(plane)].denominator = (v_fract_den), \
.bpp[(plane)] = (_bpp)
/*
* struct fract - Represents a fraction
* @numerator: Store the numerator part of the fraction
* @denominator: Store the denominator part of the fraction
*/
struct fract {
u8 numerator;
u8 denominator;
};
/*
* struct camss_format_info - ISP media bus format information
* @code: V4L2 media bus format code
* @mbus_bpp: Media bus bits per pixel
* @pixelformat: V4L2 pixel format FCC identifier
* @planes: Number of planes
* @hsub: Horizontal subsampling (for each plane)
* @vsub: Vertical subsampling (for each plane)
* @bpp: Bits per pixel when stored in memory (for each plane)
*/
struct camss_format_info {
u32 code;
u32 mbus_bpp;
u32 pixelformat;
u8 planes;
struct fract hsub[3];
struct fract vsub[3];
unsigned int bpp[3];
};
struct camss_formats {
unsigned int nformats;
const struct camss_format_info *formats;
};
#endif /* __CAMSS_FORMAT_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;
......
......@@ -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;
......@@ -53,7 +51,7 @@ struct camss_video {
};
int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev,
const char *name, int is_pix);
const char *name);
void msm_video_unregister(struct camss_video *video);
......
......@@ -137,7 +137,9 @@ static const struct camss_subdev_resources vfe_res_8x16[] = {
.interrupt = { "vfe0" },
.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
}
}
};
......@@ -303,7 +305,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
}
},
......@@ -326,7 +330,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
}
}
};
......@@ -513,7 +519,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
}
},
......@@ -539,7 +547,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
}
}
};
......@@ -724,7 +734,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
}
},
......@@ -749,7 +761,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
}
},
......@@ -773,7 +787,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
}
}
};
......@@ -938,7 +954,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 */
......@@ -962,7 +980,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) */
......@@ -984,7 +1004,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) */
......@@ -1006,7 +1028,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
}
},
};
......@@ -1216,7 +1240,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 */
......@@ -1234,7 +1260,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 */
......@@ -1252,7 +1280,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 */
......@@ -1270,7 +1300,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 */
......@@ -1287,7 +1319,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 */
......@@ -1304,7 +1338,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 */
......@@ -1321,7 +1357,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 */
......@@ -1338,7 +1376,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
}
},
};
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment