Changes since v2:
- 1/6, Added a phrase that the format is opaque (Hans).
- 6/6, new patch to address an issue with reconfigure.
regards,
Stan
Stanimir Varbanov (6):
v4l: Add Qualcomm custom compressed pixel formats
venus: helpers: Add helper to check supported pixel formats
venus: Add a handling of QC08C compressed format
venus: hfi_platform: Correct supported compressed format
venus: Add a handling of QC10C compressed format
venus: vdec: Use output resolution on reconfigure
.../media/v4l/pixfmt-reserved.rst | 19 +++++++
drivers/media/platform/qcom/venus/helpers.c | 51 +++++++++++--------
drivers/media/platform/qcom/venus/helpers.h | 1 +
.../platform/qcom/venus/hfi_platform_v4.c | 4 +-
.../platform/qcom/venus/hfi_platform_v6.c | 4 +-
drivers/media/platform/qcom/venus/vdec.c | 35 +++++++++++--
drivers/media/v4l2-core/v4l2-ioctl.c | 2 +
include/uapi/linux/videodev2.h | 2 +
8 files changed, 87 insertions(+), 31 deletions(-)
--
2.25.1
When recalculate output buffer size we have to take into account
the output resolution from the firmware received during event change
notification.
Signed-off-by: Stanimir Varbanov <[email protected]>
---
drivers/media/platform/qcom/venus/vdec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index c8261c6cb0fb..76716ceb3e18 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -701,8 +701,8 @@ static int vdec_output_conf(struct venus_inst *inst)
struct venus_core *core = inst->core;
struct hfi_enable en = { .enable = 1 };
struct hfi_buffer_requirements bufreq;
- u32 width = inst->out_width;
- u32 height = inst->out_height;
+ u32 width = inst->width;
+ u32 height = inst->height;
u32 out_fmt, out2_fmt;
bool ubwc = false;
u32 ptype;
--
2.25.1
This adds QC10C compressed pixel format in the Venus driver, and
make it possible to discover from v4l2 clients.
Note: The QC10C format shouldn't be possible to discpver by the
client if the decoded bitstream is not 10-bits.
Signed-off-by: Stanimir Varbanov <[email protected]>
---
drivers/media/platform/qcom/venus/helpers.c | 26 ++++-----------------
drivers/media/platform/qcom/venus/vdec.c | 19 ++++++++++++---
2 files changed, 20 insertions(+), 25 deletions(-)
diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index adbfa4fbe139..69a9a9471a27 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -594,6 +594,8 @@ static u32 to_hfi_raw_fmt(u32 v4l2_fmt)
return HFI_COLOR_FORMAT_NV21;
case V4L2_PIX_FMT_QC08C:
return HFI_COLOR_FORMAT_NV12_UBWC;
+ case V4L2_PIX_FMT_QC10C:
+ return HFI_COLOR_FORMAT_YUV420_TP10_UBWC;
default:
break;
}
@@ -1176,7 +1178,8 @@ int venus_helper_set_format_constraints(struct venus_inst *inst)
if (!IS_V6(inst->core))
return 0;
- if (inst->opb_fmt == HFI_COLOR_FORMAT_NV12_UBWC)
+ if (inst->opb_fmt == HFI_COLOR_FORMAT_NV12_UBWC ||
+ inst->opb_fmt == HFI_COLOR_FORMAT_YUV420_TP10_UBWC)
return 0;
pconstraint.buffer_type = HFI_BUFFER_OUTPUT2;
@@ -1747,27 +1750,6 @@ int venus_helper_get_out_fmts(struct venus_inst *inst, u32 v4l2_fmt,
if (!caps)
return -EINVAL;
- if (inst->bit_depth == VIDC_BITDEPTH_10 &&
- inst->session_type == VIDC_SESSION_TYPE_DEC) {
- found_ubwc =
- find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT,
- HFI_COLOR_FORMAT_YUV420_TP10_UBWC);
- found = find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT2,
- HFI_COLOR_FORMAT_NV12);
- if (found_ubwc && found) {
- /*
- * Hard-code DPB buffers to be 10bit UBWC and decoder
- * output buffers in 8bit NV12 until V4L2 is able to
- * expose compressed/tiled formats to applications.
- */
- *out_fmt = HFI_COLOR_FORMAT_YUV420_TP10_UBWC;
- *out2_fmt = HFI_COLOR_FORMAT_NV12;
- return 0;
- }
-
- return -EINVAL;
- }
-
if (ubwc) {
ubwc_fmt = fmt | HFI_COLOR_FORMAT_UBWC_BASE;
found_ubwc = find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT,
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index eb02e45a512b..c8261c6cb0fb 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -35,6 +35,10 @@ static const struct venus_format vdec_formats[] = {
.num_planes = 1,
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
}, {
+ .pixfmt = V4L2_PIX_FMT_QC10C,
+ .num_planes = 1,
+ .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
+ },{
.pixfmt = V4L2_PIX_FMT_NV12,
.num_planes = 1,
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
@@ -114,6 +118,10 @@ find_format(struct venus_inst *inst, u32 pixfmt, u32 type)
!venus_helper_check_format(inst, fmt[i].pixfmt))
return NULL;
+ if (V4L2_TYPE_IS_CAPTURE(type) && fmt[i].pixfmt == V4L2_PIX_FMT_QC10C &&
+ !(inst->bit_depth == VIDC_BITDEPTH_10))
+ return NULL;
+
return &fmt[i];
}
@@ -133,11 +141,16 @@ find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type)
if (fmt[i].type != type)
continue;
- if (V4L2_TYPE_IS_OUTPUT(type))
+ if (V4L2_TYPE_IS_OUTPUT(type)) {
valid = venus_helper_check_codec(inst, fmt[i].pixfmt);
- else if (V4L2_TYPE_IS_CAPTURE(type))
+ } else if (V4L2_TYPE_IS_CAPTURE(type)) {
valid = venus_helper_check_format(inst, fmt[i].pixfmt);
+ if (fmt[i].pixfmt == V4L2_PIX_FMT_QC10C &&
+ !(inst->bit_depth == VIDC_BITDEPTH_10))
+ valid = false;
+ }
+
if (k == index && valid)
break;
if (valid)
@@ -1537,7 +1550,7 @@ static const struct hfi_inst_ops vdec_hfi_ops = {
static void vdec_inst_init(struct venus_inst *inst)
{
inst->hfi_codec = HFI_VIDEO_CODEC_H264;
- inst->fmt_out = &vdec_formats[7];
+ inst->fmt_out = &vdec_formats[8];
inst->fmt_cap = &vdec_formats[0];
inst->width = frame_width_min(inst);
inst->height = ALIGN(frame_height_min(inst), 32);
--
2.25.1
This adds QC08C compressed pixel format in the Venus driver, and
make it possible to discover from v4l2 clients.
Signed-off-by: Stanimir Varbanov <[email protected]>
---
drivers/media/platform/qcom/venus/helpers.c | 2 ++
drivers/media/platform/qcom/venus/vdec.c | 18 +++++++++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index a5464385a716..adbfa4fbe139 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -592,6 +592,8 @@ static u32 to_hfi_raw_fmt(u32 v4l2_fmt)
return HFI_COLOR_FORMAT_NV12;
case V4L2_PIX_FMT_NV21:
return HFI_COLOR_FORMAT_NV21;
+ case V4L2_PIX_FMT_QC08C:
+ return HFI_COLOR_FORMAT_NV12_UBWC;
default:
break;
}
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index 91da3f509724..eb02e45a512b 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -31,6 +31,10 @@
*/
static const struct venus_format vdec_formats[] = {
{
+ .pixfmt = V4L2_PIX_FMT_QC08C,
+ .num_planes = 1,
+ .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
+ }, {
.pixfmt = V4L2_PIX_FMT_NV12,
.num_planes = 1,
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
@@ -106,6 +110,10 @@ find_format(struct venus_inst *inst, u32 pixfmt, u32 type)
!venus_helper_check_codec(inst, fmt[i].pixfmt))
return NULL;
+ if (V4L2_TYPE_IS_CAPTURE(type) &&
+ !venus_helper_check_format(inst, fmt[i].pixfmt))
+ return NULL;
+
return &fmt[i];
}
@@ -124,8 +132,12 @@ find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type)
if (fmt[i].type != type)
continue;
- valid = type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ||
- venus_helper_check_codec(inst, fmt[i].pixfmt);
+
+ if (V4L2_TYPE_IS_OUTPUT(type))
+ valid = venus_helper_check_codec(inst, fmt[i].pixfmt);
+ else if (V4L2_TYPE_IS_CAPTURE(type))
+ valid = venus_helper_check_format(inst, fmt[i].pixfmt);
+
if (k == index && valid)
break;
if (valid)
@@ -1525,7 +1537,7 @@ static const struct hfi_inst_ops vdec_hfi_ops = {
static void vdec_inst_init(struct venus_inst *inst)
{
inst->hfi_codec = HFI_VIDEO_CODEC_H264;
- inst->fmt_out = &vdec_formats[6];
+ inst->fmt_out = &vdec_formats[7];
inst->fmt_cap = &vdec_formats[0];
inst->width = frame_width_min(inst);
inst->height = ALIGN(frame_height_min(inst), 32);
--
2.25.1
Add a helper to check supported pixel format per codec and session
type.
Signed-off-by: Stanimir Varbanov <[email protected]>
---
drivers/media/platform/qcom/venus/helpers.c | 23 +++++++++++++++++++++
drivers/media/platform/qcom/venus/helpers.h | 1 +
2 files changed, 24 insertions(+)
diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index 84c3a511ec31..a5464385a716 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -1797,6 +1797,29 @@ int venus_helper_get_out_fmts(struct venus_inst *inst, u32 v4l2_fmt,
}
EXPORT_SYMBOL_GPL(venus_helper_get_out_fmts);
+bool venus_helper_check_format(struct venus_inst *inst, u32 v4l2_pixfmt)
+{
+ struct venus_core *core = inst->core;
+ u32 fmt = to_hfi_raw_fmt(v4l2_pixfmt);
+ struct hfi_plat_caps *caps;
+ u32 buftype;
+
+ if (!fmt)
+ return false;
+
+ caps = venus_caps_by_codec(core, inst->hfi_codec, inst->session_type);
+ if (!caps)
+ return false;
+
+ if (inst->session_type == VIDC_SESSION_TYPE_DEC)
+ buftype = HFI_BUFFER_OUTPUT2;
+ else
+ buftype = HFI_BUFFER_OUTPUT;
+
+ return find_fmt_from_caps(caps, buftype, fmt);
+}
+EXPORT_SYMBOL_GPL(venus_helper_check_format);
+
int venus_helper_set_stride(struct venus_inst *inst,
unsigned int width, unsigned int height)
{
diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h
index 32619c3e8c97..358e4f39c9c0 100644
--- a/drivers/media/platform/qcom/venus/helpers.h
+++ b/drivers/media/platform/qcom/venus/helpers.h
@@ -55,6 +55,7 @@ void venus_helper_init_instance(struct venus_inst *inst);
int venus_helper_session_init(struct venus_inst *inst);
int venus_helper_get_out_fmts(struct venus_inst *inst, u32 fmt, u32 *out_fmt,
u32 *out2_fmt, bool ubwc);
+bool venus_helper_check_format(struct venus_inst *inst, u32 v4l2_pixfmt);
int venus_helper_alloc_dpb_bufs(struct venus_inst *inst);
int venus_helper_free_dpb_bufs(struct venus_inst *inst);
int venus_helper_intbufs_alloc(struct venus_inst *inst);
--
2.25.1
Add custom Qualcomm raw compressed pixel formats. They are
used in Qualcomm SoCs to optimize the interconnect bandwidth.
Signed-off-by: Stanimir Varbanov <[email protected]>
---
.../media/v4l/pixfmt-reserved.rst | 19 +++++++++++++++++++
drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++
include/uapi/linux/videodev2.h | 2 ++
3 files changed, 23 insertions(+)
diff --git a/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst b/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
index 2f2133b4cd9c..929bd0dc0ba3 100644
--- a/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
+++ b/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
@@ -245,6 +245,25 @@ please make a proposal on the linux-media mailing list.
- Non-compressed, tiled two-planar format used by Mediatek MT8183.
This is an opaque intermediate format and the MDP3 hardware can be
used to convert it to other formats.
+ * .. _V4L2-PIX-FMT-QC08C:
+
+ - ``V4L2_PIX_FMT_QC08C``
+ - 'QC08C'
+ - Compressed Macro-tile 8-Bit YUV420 format used by Qualcomm platforms.
+ It is an opaque intermediate format. The used compression is lossless
+ and it is used by various multimedia hardware blocks like GPU, display
+ controllers, ISP and video accelerators.
+ It contains four planes for progressive video and eight planes for
+ interlaced video.
+ * .. _V4L2-PIX-FMT-QC10C:
+
+ - ``V4L2_PIX_FMT_QC10C``
+ - 'QC10C'
+ - Compressed Macro-tile 10-Bit YUV420 format used by Qualcomm platforms.
+ It is an opaque intermediate format. The used compression is lossless
+ and it is used by various multimedia hardware blocks like GPU, display
+ controllers, ISP and video accelerators.
+ It contains four planes for progressive video.
.. raw:: latex
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 9ac557b8e146..1b6462f9ad7e 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1437,6 +1437,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_PIX_FMT_SE401: descr = "GSPCA SE401"; break;
case V4L2_PIX_FMT_S5C_UYVY_JPG: descr = "S5C73MX interleaved UYVY/JPEG"; break;
case V4L2_PIX_FMT_MT21C: descr = "Mediatek Compressed Format"; break;
+ case V4L2_PIX_FMT_QC08C: descr = "QCOM Compressed 8-bit Format"; break;
+ case V4L2_PIX_FMT_QC10C: descr = "QCOM Compressed 10-bit Format"; break;
default:
if (fmt->description[0])
return;
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index df8b9c486ba1..e710903185bd 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -744,6 +744,8 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I') /* Intel Planar Greyscale 10-bit and Depth 16-bit */
#define V4L2_PIX_FMT_CNF4 v4l2_fourcc('C', 'N', 'F', '4') /* Intel 4-bit packed depth confidence information */
#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* BTTV 8-bit dithered RGB */
+#define V4L2_PIX_FMT_QC08C v4l2_fourcc('Q', '0', '8', 'C') /* Qualcomm 8-bit compressed */
+#define V4L2_PIX_FMT_QC10C v4l2_fourcc('Q', '1', '0', 'C') /* Qualcomm 10-bit compressed */
/* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */
#define V4L2_PIX_FMT_IPU3_SBGGR10 v4l2_fourcc('i', 'p', '3', 'b') /* IPU3 packed 10-bit BGGR bayer */
--
2.25.1
In multistream mode HFI supports TP10_UBWC on output2. Correct this
in supported formats capabilities list.
Signed-off-by: Stanimir Varbanov <[email protected]>
---
drivers/media/platform/qcom/venus/hfi_platform_v4.c | 4 ++--
drivers/media/platform/qcom/venus/hfi_platform_v6.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/qcom/venus/hfi_platform_v4.c b/drivers/media/platform/qcom/venus/hfi_platform_v4.c
index 3f7f5277a50e..e3f0a90a567b 100644
--- a/drivers/media/platform/qcom/venus/hfi_platform_v4.c
+++ b/drivers/media/platform/qcom/venus/hfi_platform_v4.c
@@ -55,7 +55,7 @@ static const struct hfi_plat_caps caps[] = {
.fmts[3] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_NV12},
.fmts[4] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_NV21},
.fmts[5] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_P010},
- .fmts[6] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_YUV420_TP10},
+ .fmts[6] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_YUV420_TP10_UBWC},
.num_fmts = 7,
}, {
.codec = HFI_VIDEO_CODEC_VP8,
@@ -106,7 +106,7 @@ static const struct hfi_plat_caps caps[] = {
.fmts[3] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_NV12},
.fmts[4] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_NV21},
.fmts[5] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_P010},
- .fmts[6] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_YUV420_TP10},
+ .fmts[6] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_YUV420_TP10_UBWC},
.num_fmts = 7,
}, {
.codec = HFI_VIDEO_CODEC_MPEG2,
diff --git a/drivers/media/platform/qcom/venus/hfi_platform_v6.c b/drivers/media/platform/qcom/venus/hfi_platform_v6.c
index c10618e44f5d..4e8af645f8b9 100644
--- a/drivers/media/platform/qcom/venus/hfi_platform_v6.c
+++ b/drivers/media/platform/qcom/venus/hfi_platform_v6.c
@@ -55,7 +55,7 @@ static const struct hfi_plat_caps caps[] = {
.fmts[3] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_NV12},
.fmts[4] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_NV21},
.fmts[5] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_P010},
- .fmts[6] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_YUV420_TP10},
+ .fmts[6] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_YUV420_TP10_UBWC},
.num_fmts = 7,
}, {
.codec = HFI_VIDEO_CODEC_VP8,
@@ -106,7 +106,7 @@ static const struct hfi_plat_caps caps[] = {
.fmts[3] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_NV12},
.fmts[4] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_NV21},
.fmts[5] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_P010},
- .fmts[6] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_YUV420_TP10},
+ .fmts[6] = {HFI_BUFFER_OUTPUT2, HFI_COLOR_FORMAT_YUV420_TP10_UBWC},
.num_fmts = 7,
}, {
.codec = HFI_VIDEO_CODEC_MPEG2,
--
2.25.1
On Mon, Jan 17, 2022 at 6:36 PM Stanimir Varbanov
<[email protected]> wrote:
>
> Add custom Qualcomm raw compressed pixel formats. They are
> used in Qualcomm SoCs to optimize the interconnect bandwidth.
>
> Signed-off-by: Stanimir Varbanov <[email protected]>
> ---
> .../media/v4l/pixfmt-reserved.rst | 19 +++++++++++++++++++
> drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++
> include/uapi/linux/videodev2.h | 2 ++
> 3 files changed, 23 insertions(+)
>
> diff --git a/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst b/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
> index 2f2133b4cd9c..929bd0dc0ba3 100644
> --- a/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
> +++ b/Documentation/userspace-api/media/v4l/pixfmt-reserved.rst
> @@ -245,6 +245,25 @@ please make a proposal on the linux-media mailing list.
> - Non-compressed, tiled two-planar format used by Mediatek MT8183.
> This is an opaque intermediate format and the MDP3 hardware can be
> used to convert it to other formats.
> + * .. _V4L2-PIX-FMT-QC08C:
> +
> + - ``V4L2_PIX_FMT_QC08C``
> + - 'QC08C'
> + - Compressed Macro-tile 8-Bit YUV420 format used by Qualcomm platforms.
> + It is an opaque intermediate format. The used compression is lossless
> + and it is used by various multimedia hardware blocks like GPU, display
> + controllers, ISP and video accelerators.
> + It contains four planes for progressive video and eight planes for
> + interlaced video.
I guess QC08C is the same thing as NV12+UBWC? Note that on the GPU
side, NV12+UBWC is treated as two planes, we program the hw with the
address of the start of UBWC data and the hw calculates the offset to
pixel data for the plane. So the UBWC and pixel data are not actually
independent planes.
BR,
-R
> + * .. _V4L2-PIX-FMT-QC10C:
> +
> + - ``V4L2_PIX_FMT_QC10C``
> + - 'QC10C'
> + - Compressed Macro-tile 10-Bit YUV420 format used by Qualcomm platforms.
> + It is an opaque intermediate format. The used compression is lossless
> + and it is used by various multimedia hardware blocks like GPU, display
> + controllers, ISP and video accelerators.
> + It contains four planes for progressive video.
>
> .. raw:: latex
>
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 9ac557b8e146..1b6462f9ad7e 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -1437,6 +1437,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
> case V4L2_PIX_FMT_SE401: descr = "GSPCA SE401"; break;
> case V4L2_PIX_FMT_S5C_UYVY_JPG: descr = "S5C73MX interleaved UYVY/JPEG"; break;
> case V4L2_PIX_FMT_MT21C: descr = "Mediatek Compressed Format"; break;
> + case V4L2_PIX_FMT_QC08C: descr = "QCOM Compressed 8-bit Format"; break;
> + case V4L2_PIX_FMT_QC10C: descr = "QCOM Compressed 10-bit Format"; break;
> default:
> if (fmt->description[0])
> return;
> diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
> index df8b9c486ba1..e710903185bd 100644
> --- a/include/uapi/linux/videodev2.h
> +++ b/include/uapi/linux/videodev2.h
> @@ -744,6 +744,8 @@ struct v4l2_pix_format {
> #define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I') /* Intel Planar Greyscale 10-bit and Depth 16-bit */
> #define V4L2_PIX_FMT_CNF4 v4l2_fourcc('C', 'N', 'F', '4') /* Intel 4-bit packed depth confidence information */
> #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* BTTV 8-bit dithered RGB */
> +#define V4L2_PIX_FMT_QC08C v4l2_fourcc('Q', '0', '8', 'C') /* Qualcomm 8-bit compressed */
> +#define V4L2_PIX_FMT_QC10C v4l2_fourcc('Q', '1', '0', 'C') /* Qualcomm 10-bit compressed */
>
> /* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */
> #define V4L2_PIX_FMT_IPU3_SBGGR10 v4l2_fourcc('i', 'p', '3', 'b') /* IPU3 packed 10-bit BGGR bayer */
> --
> 2.25.1
>
Le lundi 17 janvier 2022 à 17:55 +0200, Stanimir Varbanov a écrit :
> This adds QC10C compressed pixel format in the Venus driver, and
> make it possible to discover from v4l2 clients.
>
> Note: The QC10C format shouldn't be possible to discpver by the
discpver -> discover
It is not super clear though, did you mean to say that it won't be enumerated
after the header have been parsed ?
> client if the decoded bitstream is not 10-bits.
>
> Signed-off-by: Stanimir Varbanov <[email protected]>
> ---
> drivers/media/platform/qcom/venus/helpers.c | 26 ++++-----------------
> drivers/media/platform/qcom/venus/vdec.c | 19 ++++++++++++---
> 2 files changed, 20 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
> index adbfa4fbe139..69a9a9471a27 100644
> --- a/drivers/media/platform/qcom/venus/helpers.c
> +++ b/drivers/media/platform/qcom/venus/helpers.c
> @@ -594,6 +594,8 @@ static u32 to_hfi_raw_fmt(u32 v4l2_fmt)
> return HFI_COLOR_FORMAT_NV21;
> case V4L2_PIX_FMT_QC08C:
> return HFI_COLOR_FORMAT_NV12_UBWC;
> + case V4L2_PIX_FMT_QC10C:
> + return HFI_COLOR_FORMAT_YUV420_TP10_UBWC;
> default:
> break;
> }
> @@ -1176,7 +1178,8 @@ int venus_helper_set_format_constraints(struct venus_inst *inst)
> if (!IS_V6(inst->core))
> return 0;
>
> - if (inst->opb_fmt == HFI_COLOR_FORMAT_NV12_UBWC)
> + if (inst->opb_fmt == HFI_COLOR_FORMAT_NV12_UBWC ||
> + inst->opb_fmt == HFI_COLOR_FORMAT_YUV420_TP10_UBWC)
> return 0;
>
> pconstraint.buffer_type = HFI_BUFFER_OUTPUT2;
> @@ -1747,27 +1750,6 @@ int venus_helper_get_out_fmts(struct venus_inst *inst, u32 v4l2_fmt,
> if (!caps)
> return -EINVAL;
>
> - if (inst->bit_depth == VIDC_BITDEPTH_10 &&
> - inst->session_type == VIDC_SESSION_TYPE_DEC) {
> - found_ubwc =
> - find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT,
> - HFI_COLOR_FORMAT_YUV420_TP10_UBWC);
> - found = find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT2,
> - HFI_COLOR_FORMAT_NV12);
> - if (found_ubwc && found) {
> - /*
> - * Hard-code DPB buffers to be 10bit UBWC and decoder
> - * output buffers in 8bit NV12 until V4L2 is able to
> - * expose compressed/tiled formats to applications.
> - */
> - *out_fmt = HFI_COLOR_FORMAT_YUV420_TP10_UBWC;
> - *out2_fmt = HFI_COLOR_FORMAT_NV12;
> - return 0;
> - }
> -
> - return -EINVAL;
> - }
> -
> if (ubwc) {
> ubwc_fmt = fmt | HFI_COLOR_FORMAT_UBWC_BASE;
> found_ubwc = find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT,
> diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
> index eb02e45a512b..c8261c6cb0fb 100644
> --- a/drivers/media/platform/qcom/venus/vdec.c
> +++ b/drivers/media/platform/qcom/venus/vdec.c
> @@ -35,6 +35,10 @@ static const struct venus_format vdec_formats[] = {
> .num_planes = 1,
> .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
> }, {
> + .pixfmt = V4L2_PIX_FMT_QC10C,
> + .num_planes = 1,
> + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
> + },{
> .pixfmt = V4L2_PIX_FMT_NV12,
> .num_planes = 1,
> .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
> @@ -114,6 +118,10 @@ find_format(struct venus_inst *inst, u32 pixfmt, u32 type)
> !venus_helper_check_format(inst, fmt[i].pixfmt))
> return NULL;
>
> + if (V4L2_TYPE_IS_CAPTURE(type) && fmt[i].pixfmt == V4L2_PIX_FMT_QC10C &&
> + !(inst->bit_depth == VIDC_BITDEPTH_10))
> + return NULL;
> +
> return &fmt[i];
> }
>
> @@ -133,11 +141,16 @@ find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type)
> if (fmt[i].type != type)
> continue;
>
> - if (V4L2_TYPE_IS_OUTPUT(type))
> + if (V4L2_TYPE_IS_OUTPUT(type)) {
> valid = venus_helper_check_codec(inst, fmt[i].pixfmt);
> - else if (V4L2_TYPE_IS_CAPTURE(type))
> + } else if (V4L2_TYPE_IS_CAPTURE(type)) {
> valid = venus_helper_check_format(inst, fmt[i].pixfmt);
>
> + if (fmt[i].pixfmt == V4L2_PIX_FMT_QC10C &&
> + !(inst->bit_depth == VIDC_BITDEPTH_10))
> + valid = false;
> + }
> +
> if (k == index && valid)
> break;
> if (valid)
> @@ -1537,7 +1550,7 @@ static const struct hfi_inst_ops vdec_hfi_ops = {
> static void vdec_inst_init(struct venus_inst *inst)
> {
> inst->hfi_codec = HFI_VIDEO_CODEC_H264;
> - inst->fmt_out = &vdec_formats[7];
> + inst->fmt_out = &vdec_formats[8];
> inst->fmt_cap = &vdec_formats[0];
> inst->width = frame_width_min(inst);
> inst->height = ALIGN(frame_height_min(inst), 32);
On 2/16/22 18:20, Nicolas Dufresne wrote:
> Le lundi 17 janvier 2022 à 17:55 +0200, Stanimir Varbanov a écrit :
>> This adds QC10C compressed pixel format in the Venus driver, and
>> make it possible to discover from v4l2 clients.
>>
>> Note: The QC10C format shouldn't be possible to discpver by the
>
> discpver -> discover
>
> It is not super clear though, did you mean to say that it won't be enumerated
> after the header have been parsed ?
The opposite. It will be enumerable by the client only after parsing the
header.
>
>> client if the decoded bitstream is not 10-bits.
>>
>> Signed-off-by: Stanimir Varbanov <[email protected]>
>> ---
>> drivers/media/platform/qcom/venus/helpers.c | 26 ++++-----------------
>> drivers/media/platform/qcom/venus/vdec.c | 19 ++++++++++++---
>> 2 files changed, 20 insertions(+), 25 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
>> index adbfa4fbe139..69a9a9471a27 100644
>> --- a/drivers/media/platform/qcom/venus/helpers.c
>> +++ b/drivers/media/platform/qcom/venus/helpers.c
>> @@ -594,6 +594,8 @@ static u32 to_hfi_raw_fmt(u32 v4l2_fmt)
>> return HFI_COLOR_FORMAT_NV21;
>> case V4L2_PIX_FMT_QC08C:
>> return HFI_COLOR_FORMAT_NV12_UBWC;
>> + case V4L2_PIX_FMT_QC10C:
>> + return HFI_COLOR_FORMAT_YUV420_TP10_UBWC;
>> default:
>> break;
>> }
>> @@ -1176,7 +1178,8 @@ int venus_helper_set_format_constraints(struct venus_inst *inst)
>> if (!IS_V6(inst->core))
>> return 0;
>>
>> - if (inst->opb_fmt == HFI_COLOR_FORMAT_NV12_UBWC)
>> + if (inst->opb_fmt == HFI_COLOR_FORMAT_NV12_UBWC ||
>> + inst->opb_fmt == HFI_COLOR_FORMAT_YUV420_TP10_UBWC)
>> return 0;
>>
>> pconstraint.buffer_type = HFI_BUFFER_OUTPUT2;
>> @@ -1747,27 +1750,6 @@ int venus_helper_get_out_fmts(struct venus_inst *inst, u32 v4l2_fmt,
>> if (!caps)
>> return -EINVAL;
>>
>> - if (inst->bit_depth == VIDC_BITDEPTH_10 &&
>> - inst->session_type == VIDC_SESSION_TYPE_DEC) {
>> - found_ubwc =
>> - find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT,
>> - HFI_COLOR_FORMAT_YUV420_TP10_UBWC);
>> - found = find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT2,
>> - HFI_COLOR_FORMAT_NV12);
>> - if (found_ubwc && found) {
>> - /*
>> - * Hard-code DPB buffers to be 10bit UBWC and decoder
>> - * output buffers in 8bit NV12 until V4L2 is able to
>> - * expose compressed/tiled formats to applications.
>> - */
>> - *out_fmt = HFI_COLOR_FORMAT_YUV420_TP10_UBWC;
>> - *out2_fmt = HFI_COLOR_FORMAT_NV12;
>> - return 0;
>> - }
>> -
>> - return -EINVAL;
>> - }
>> -
>> if (ubwc) {
>> ubwc_fmt = fmt | HFI_COLOR_FORMAT_UBWC_BASE;
>> found_ubwc = find_fmt_from_caps(caps, HFI_BUFFER_OUTPUT,
>> diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
>> index eb02e45a512b..c8261c6cb0fb 100644
>> --- a/drivers/media/platform/qcom/venus/vdec.c
>> +++ b/drivers/media/platform/qcom/venus/vdec.c
>> @@ -35,6 +35,10 @@ static const struct venus_format vdec_formats[] = {
>> .num_planes = 1,
>> .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
>> }, {
>> + .pixfmt = V4L2_PIX_FMT_QC10C,
>> + .num_planes = 1,
>> + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
>> + },{
>> .pixfmt = V4L2_PIX_FMT_NV12,
>> .num_planes = 1,
>> .type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
>> @@ -114,6 +118,10 @@ find_format(struct venus_inst *inst, u32 pixfmt, u32 type)
>> !venus_helper_check_format(inst, fmt[i].pixfmt))
>> return NULL;
>>
>> + if (V4L2_TYPE_IS_CAPTURE(type) && fmt[i].pixfmt == V4L2_PIX_FMT_QC10C &&
>> + !(inst->bit_depth == VIDC_BITDEPTH_10))
>> + return NULL;
>> +
>> return &fmt[i];
>> }
>>
>> @@ -133,11 +141,16 @@ find_format_by_index(struct venus_inst *inst, unsigned int index, u32 type)
>> if (fmt[i].type != type)
>> continue;
>>
>> - if (V4L2_TYPE_IS_OUTPUT(type))
>> + if (V4L2_TYPE_IS_OUTPUT(type)) {
>> valid = venus_helper_check_codec(inst, fmt[i].pixfmt);
>> - else if (V4L2_TYPE_IS_CAPTURE(type))
>> + } else if (V4L2_TYPE_IS_CAPTURE(type)) {
>> valid = venus_helper_check_format(inst, fmt[i].pixfmt);
>>
>> + if (fmt[i].pixfmt == V4L2_PIX_FMT_QC10C &&
>> + !(inst->bit_depth == VIDC_BITDEPTH_10))
>> + valid = false;
>> + }
>> +
>> if (k == index && valid)
>> break;
>> if (valid)
>> @@ -1537,7 +1550,7 @@ static const struct hfi_inst_ops vdec_hfi_ops = {
>> static void vdec_inst_init(struct venus_inst *inst)
>> {
>> inst->hfi_codec = HFI_VIDEO_CODEC_H264;
>> - inst->fmt_out = &vdec_formats[7];
>> + inst->fmt_out = &vdec_formats[8];
>> inst->fmt_cap = &vdec_formats[0];
>> inst->width = frame_width_min(inst);
>> inst->height = ALIGN(frame_height_min(inst), 32);
>
--
regards,
Stan