Эх сурвалжийг харах

Merge "video: driver: Add support for AV1 film grain"

qctecmdr 3 жил өмнө
parent
commit
960ac904d2

+ 1 - 1
driver/platform/kalama/src/msm_vidc_kalama.c

@@ -1473,7 +1473,7 @@ static struct msm_platform_inst_capability instance_data_kalama[] = {
 	{FILM_GRAIN, DEC, AV1,
 		V4L2_MPEG_MSM_VIDC_DISABLE, V4L2_MPEG_MSM_VIDC_ENABLE,
 		1, V4L2_MPEG_MSM_VIDC_DISABLE,
-		0,
+		V4L2_CID_MPEG_VIDC_AV1D_FILM_GRAIN_PRESENT,
 		HFI_PROP_AV1_FILM_GRAIN_PRESENT},
 
 	{SUPER_BLOCK, DEC, AV1,

+ 14 - 4
driver/variant/iris3/src/msm_vidc_buffer_iris3.c

@@ -220,15 +220,22 @@ static u32 msm_vidc_decoder_dpb_size_iris3(struct msm_vidc_inst *inst)
 		return size;
 	}
 
+	/*
+	 * For legacy codecs (non-AV1), DPB is calculated only
+	 * for linear formats. For AV1, DPB is needed for film-grain
+	 * enabled bitstreams (UBWC & linear).
+	 */
 	color_fmt = inst->capabilities->cap[PIX_FMTS].value;
-	if (!is_linear_colorformat(color_fmt))
+	if (!is_linear_colorformat(color_fmt) &&
+		inst->codec != MSM_VIDC_AV1)
 		return size;
 
 	f = &inst->fmts[OUTPUT_PORT];
 	width = f->fmt.pix_mp.width;
 	height = f->fmt.pix_mp.height;
 
-	if (color_fmt == MSM_VIDC_FMT_NV12) {
+	if (color_fmt == MSM_VIDC_FMT_NV12 ||
+		color_fmt == MSM_VIDC_FMT_NV12C) {
 		v4l2_fmt = V4L2_PIX_FMT_VIDC_NV12C;
 		HFI_NV12_UBWC_IL_CALC_BUF_SIZE_V2(size, width, height,
 			VIDEO_Y_STRIDE_BYTES(v4l2_fmt, width), VIDEO_Y_SCANLINES(v4l2_fmt, height),
@@ -237,7 +244,8 @@ static u32 msm_vidc_decoder_dpb_size_iris3(struct msm_vidc_inst *inst)
 				height),
 			VIDEO_UV_META_STRIDE(v4l2_fmt, width), VIDEO_UV_META_SCANLINES(v4l2_fmt,
 				height));
-	} else if (color_fmt == MSM_VIDC_FMT_P010) {
+	} else if (color_fmt == MSM_VIDC_FMT_P010 ||
+		color_fmt == MSM_VIDC_FMT_TP10C) {
 		v4l2_fmt = V4L2_PIX_FMT_VIDC_TP10C;
 		HFI_YUV420_TP10_UBWC_CALC_BUF_SIZE(size,
 			VIDEO_Y_STRIDE_BYTES(v4l2_fmt, width), VIDEO_Y_SCANLINES(v4l2_fmt, height),
@@ -605,7 +613,9 @@ static int msm_buffer_dpb_count(struct msm_vidc_inst *inst)
 	/* decoder dpb buffer count */
 	if (is_decode_session(inst)) {
 		color_fmt = inst->capabilities->cap[PIX_FMTS].value;
-		if (is_linear_colorformat(color_fmt))
+		if (is_linear_colorformat(color_fmt) ||
+			(inst->codec == MSM_VIDC_AV1 &&
+			(inst->capabilities->cap[FILM_GRAIN].value)))
 			count = inst->buffers.output.min_count;
 
 		return count;

+ 12 - 5
driver/vidc/inc/msm_vidc_vb2.h

@@ -14,14 +14,21 @@ struct vb2_queue *msm_vidc_get_vb2q(struct msm_vidc_inst *inst,
 	u32 type, const char *func);
 
 /* vb2_mem_ops */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
 void *msm_vb2_get_userptr(struct device *dev, unsigned long vaddr,
 			unsigned long size, enum dma_data_direction dma_dir);
-void msm_vb2_put_userptr(void *buf_priv);
-void* msm_vb2_attach_dmabuf(struct device* dev, struct dma_buf* dbuf,
+void *msm_vb2_attach_dmabuf(struct device *dev, struct dma_buf *dbuf,
 	unsigned long size, enum dma_data_direction dma_dir);
-void msm_vb2_detach_dmabuf(void* buf_priv);
-int msm_vb2_map_dmabuf(void* buf_priv);
-void msm_vb2_unmap_dmabuf(void* buf_priv);
+#else
+void *msm_vb2_get_userptr(struct vb2_buffer *vb, struct device *dev,
+		unsigned long vaddr, unsigned long size);
+void *msm_vb2_attach_dmabuf(struct vb2_buffer *vb, struct device *dev,
+		struct dma_buf *dbuf, unsigned long size);
+#endif
+void msm_vb2_put_userptr(void *buf_priv);
+void msm_vb2_detach_dmabuf(void *buf_priv);
+int msm_vb2_map_dmabuf(void *buf_priv);
+void msm_vb2_unmap_dmabuf(void *buf_priv);
 
 /* vb2_ops */
 int msm_vidc_queue_setup(struct vb2_queue *q,

+ 34 - 0
driver/vidc/src/msm_vdec.c

@@ -600,6 +600,36 @@ static int msm_vdec_set_av1_superblock_enabled(struct msm_vidc_inst *inst,
 	return rc;
 }
 
+static int msm_vdec_set_opb_enable(struct msm_vidc_inst *inst)
+{
+	int rc = 0;
+	u32 color_fmt;
+	u32 opb_enable = 0;
+
+	if (inst->codec != MSM_VIDC_AV1)
+		return 0;
+
+	color_fmt = inst->capabilities->cap[PIX_FMTS].value;
+	if (is_linear_colorformat(color_fmt) ||
+		inst->capabilities->cap[FILM_GRAIN].value)
+		opb_enable = 1;
+
+	i_vpr_h(inst, "%s: OPB enable: %d",  __func__, opb_enable);
+	rc = venus_hfi_session_property(inst,
+			HFI_PROP_OPB_ENABLE,
+			HFI_HOST_FLAGS_NONE,
+			get_hfi_port(inst, OUTPUT_PORT),
+			HFI_PAYLOAD_U32,
+			&opb_enable,
+			sizeof(u32));
+	if (rc) {
+		i_vpr_e(inst, "%s: set property failed\n", __func__);
+		return rc;
+	}
+
+	return rc;
+}
+
 static int msm_vdec_set_colorformat(struct msm_vidc_inst *inst)
 {
 	int rc = 0;
@@ -917,6 +947,10 @@ static int msm_vdec_set_output_properties(struct msm_vidc_inst *inst)
 		return -EINVAL;
 	}
 
+	rc = msm_vdec_set_opb_enable(inst);
+	if (rc)
+		return rc;
+
 	rc = msm_vdec_set_colorformat(inst);
 	if (rc)
 		return rc;

+ 2 - 1
driver/vidc/src/msm_vidc_control.c

@@ -533,7 +533,8 @@ exit:
 void msm_vidc_add_volatile_flag(struct v4l2_ctrl *ctrl)
 {
 	if (ctrl->id == V4L2_CID_MIN_BUFFERS_FOR_OUTPUT ||
-		ctrl->id == V4L2_CID_MIN_BUFFERS_FOR_CAPTURE)
+		ctrl->id == V4L2_CID_MIN_BUFFERS_FOR_CAPTURE ||
+		ctrl->id == V4L2_CID_MPEG_VIDC_AV1D_FILM_GRAIN_PRESENT)
 		ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
 }
 

+ 5 - 0
driver/vidc/src/msm_vidc_driver.c

@@ -2027,6 +2027,11 @@ int msm_vidc_get_control(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
 			inst->buffers.input.extra_count;
 		i_vpr_h(inst, "g_min: input buffers %d\n", ctrl->val);
 		break;
+	case V4L2_CID_MPEG_VIDC_AV1D_FILM_GRAIN_PRESENT:
+		ctrl->val = inst->capabilities->cap[FILM_GRAIN].value;
+		i_vpr_h(inst, "%s: film grain present: %d\n",
+			 __func__, ctrl->val);
+		break;
 	default:
 		i_vpr_e(inst, "invalid ctrl %s id %d\n",
 			ctrl->name, ctrl->id);

+ 21 - 7
driver/vidc/src/msm_vidc_vb2.c

@@ -38,32 +38,46 @@ struct vb2_queue *msm_vidc_get_vb2q(struct msm_vidc_inst *inst,
 	return q;
 }
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0))
 void *msm_vb2_get_userptr(struct device *dev, unsigned long vaddr,
 			unsigned long size, enum dma_data_direction dma_dir)
 {
 	return (void *)0xdeadbeef;
 }
 
-void msm_vb2_put_userptr(void *buf_priv)
+void *msm_vb2_attach_dmabuf(struct device *dev, struct dma_buf *dbuf,
+	unsigned long size, enum dma_data_direction dma_dir)
+{
+	return (void *)0xdeadbeef;
+}
+#else
+void *msm_vb2_get_userptr(struct vb2_buffer *vb, struct device *dev,
+	unsigned long vaddr, unsigned long size)
+{
+	return (void *)0xdeadbeef;
+}
+
+void *msm_vb2_attach_dmabuf(struct vb2_buffer *vb, struct device *dev,
+	struct dma_buf *dbuf, unsigned long size)
 {
+	return (void *)0xdeadbeef;
 }
+#endif
 
-void* msm_vb2_attach_dmabuf(struct device* dev, struct dma_buf* dbuf,
-	unsigned long size, enum dma_data_direction dma_dir)
+void msm_vb2_put_userptr(void *buf_priv)
 {
-	return (void*)0xdeadbeef;
 }
 
-void msm_vb2_detach_dmabuf(void* buf_priv)
+void msm_vb2_detach_dmabuf(void *buf_priv)
 {
 }
 
-int msm_vb2_map_dmabuf(void* buf_priv)
+int msm_vb2_map_dmabuf(void *buf_priv)
 {
 	return 0;
 }
 
-void msm_vb2_unmap_dmabuf(void* buf_priv)
+void msm_vb2_unmap_dmabuf(void *buf_priv)
 {
 }
 

+ 3 - 0
include/uapi/vidc/media/v4l2_vidc_extensions.h

@@ -191,6 +191,9 @@ enum v4l2_mpeg_video_av1_tier {
 };
 /* Decoder Timestamp Reorder control */
 #define V4L2_CID_MPEG_VIDC_TS_REORDER           (V4L2_CID_MPEG_VIDC_BASE + 0x34)
+/* AV1 Decoder Film Grain */
+#define V4L2_CID_MPEG_VIDC_AV1D_FILM_GRAIN_PRESENT                           \
+	(V4L2_CID_MPEG_VIDC_BASE + 0x35)
 
 /* Deprecate below controls once availble in gki and gsi bionic header */
 #ifndef V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID