Browse Source

video: driver: Add NV12 related support for enc

Add support to set HFI_PROP_LINEAR_STRIDE_SCANLINE
property to video fw.

Change-Id: I0ce3549a472388a5d2471bf4c8978a5a5f524a34
Signed-off-by: Akshata Sahukar <[email protected]>
Akshata Sahukar 4 năm trước cách đây
mục cha
commit
f5a9db9667
3 tập tin đã thay đổi với 41 bổ sung35 xóa
  1. 3 3
      driver/vidc/inc/hfi_property.h
  2. 5 1
      driver/vidc/src/msm_vdec.c
  3. 33 31
      driver/vidc/src/msm_venc.c

+ 3 - 3
driver/vidc/inc/hfi_property.h

@@ -73,9 +73,9 @@ enum hfi_color_format {
 #define HFI_BITMASK_BITSTREAM_HEIGHT                            0x0000ffff
 #define HFI_PROP_BITSTREAM_RESOLUTION                           0x03000103
 
-#define HFI_BITMASK_LINEAR_STRIDE_ALIGNMENT             0xffff0000
-#define HFI_BITMASK_LINEAR_SCANLINE_ALIGNMENT           0x0000ffff
-#define HFI_PROP_LINEAR_ALIGNMENT_FACTOR                        0x03000104
+#define HFI_BITMASK_LINEAR_STRIDE             0xffff0000
+#define HFI_BITMASK_LINEAR_SCANLINE           0x0000ffff
+#define HFI_PROP_LINEAR_STRIDE_SCANLINE                        0x03000104
 
 #define HFI_BITMASK_CROP_RIGHT_OFFSET        0xffff0000
 #define HFI_BITMASK_CROP_BOTTOM_OFFSET       0x0000ffff

+ 5 - 1
driver/vidc/src/msm_vdec.c

@@ -112,7 +112,7 @@ static int msm_vdec_set_linear_stride_scanline(struct msm_vidc_inst *inst)
 		"stride_uv: %d, scanline_uv: %d", __func__,
 		stride_y, scanline_y, stride_uv, scanline_uv);
 	rc = venus_hfi_session_property(inst,
-			HFI_PROP_LINEAR_ALIGNMENT_FACTOR,
+			HFI_PROP_LINEAR_STRIDE_SCANLINE,
 			HFI_HOST_FLAGS_NONE,
 			get_hfi_port(inst, OUTPUT_PORT),
 			HFI_PAYLOAD_U64,
@@ -995,8 +995,12 @@ static int msm_vdec_subscribe_input_port_settings_change(struct msm_vidc_inst *i
 			rc = -EINVAL;
 			break;
 		}
+
+		if (rc)
+			goto exit;
 	}
 
+exit:
 	return rc;
 }
 

+ 33 - 31
driver/vidc/src/msm_venc.c

@@ -20,7 +20,7 @@
 u32 msm_venc_input_set_prop[] = {
 	HFI_PROP_COLOR_FORMAT,
 	HFI_PROP_RAW_RESOLUTION,
-	HFI_PROP_LINEAR_ALIGNMENT_FACTOR,
+	HFI_PROP_LINEAR_STRIDE_SCANLINE,
 	HFI_PROP_BUFFER_HOST_MAX_COUNT,
 };
 
@@ -75,20 +75,22 @@ static int msm_venc_set_colorformat(struct msm_vidc_inst *inst,
 	enum msm_vidc_colorformat_type colorformat;
 	u32 hfi_colorformat;
 
-	if (port != INPUT_PORT && port != OUTPUT_PORT) {
+	if (port != INPUT_PORT) {
 		i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
 		return -EINVAL;
 	}
 
 	pixelformat = inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat;
-	if (pixelformat != V4L2_PIX_FMT_VIDC_NV12C &&
-	    pixelformat != V4L2_PIX_FMT_VIDC_TP10C) {
+	colorformat = v4l2_colorformat_to_driver(pixelformat, __func__);
+	if (!(colorformat & inst->capabilities->cap[PIX_FMTS].step_or_mask)) {
 		i_vpr_e(inst, "%s: invalid pixelformat %#x\n",
 			__func__, pixelformat);
 		return -EINVAL;
 	}
-	colorformat = v4l2_colorformat_to_driver(pixelformat, __func__);
+
 	hfi_colorformat = get_hfi_colorformat(inst, colorformat);
+	i_vpr_h(inst, "%s: hfi colorformat: %#x", __func__,
+		hfi_colorformat);
 	rc = venus_hfi_session_property(inst,
 			HFI_PROP_COLOR_FORMAT,
 			HFI_HOST_FLAGS_NONE,
@@ -101,13 +103,12 @@ static int msm_venc_set_colorformat(struct msm_vidc_inst *inst,
 	return 0;
 }
 
-/* TODO: Enable when NV12 support is required */
 static int msm_venc_set_linear_alignment_factor(struct msm_vidc_inst *inst,
 	enum msm_vidc_port_type port)
 {
-/*	int rc = 0;
-	u32 pixelformat;
-	u32 alignment_factor[2];
+	int rc = 0;
+	u32 pixelformat, stride_y, scanline_y, stride_uv, scanline_uv;
+	u32 payload[2];
 
 	if (port != INPUT_PORT) {
 		i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
@@ -115,41 +116,34 @@ static int msm_venc_set_linear_alignment_factor(struct msm_vidc_inst *inst,
 	}
 
 	pixelformat = inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat;
-	if (pixelformat == V4L2_PIX_FMT_VIDC_NV12C ||
-	    pixelformat == V4L2_PIX_FMT_VIDC_TP10C ||
-		pixelformat == V4L2_PIX_FMT_VIDC_ARGB32C) {
+	if (pixelformat != V4L2_PIX_FMT_NV12 &&
+		pixelformat != V4L2_PIX_FMT_VIDC_P010) {
 		i_vpr_e(inst,
 			"%s: not a linear color fmt, property is not set\n",
 			__func__);
 		return 0;
 	}
 
-	if (pixelformat == V4L2_PIX_FMT_ARGB32) {
-		alignment_factor[0] =
-		    (rgb_stride_alignment(pixelformat, __func__) << 16) |
-		     rgb_scanline_alignment(pixelformat, __func__);
-		alignment_factor[1] = 0;
-	} else {
-		alignment_factor[0] =
-		    (y_stride_alignment(pixelformat, __func__) << 16) |
-		     y_scanline_alignment(pixelformat, __func__);
-		alignment_factor[1] =
-		    (uv_stride_alignment(pixelformat, __func__) << 16) |
-		     uv_scanline_alignment(pixelformat, __func__);
-	}
+	stride_y = inst->fmts[INPUT_PORT].fmt.pix_mp.width;
+	scanline_y = inst->fmts[INPUT_PORT].fmt.pix_mp.height;
+	stride_uv = stride_y;
+	scanline_uv = scanline_y / 2;
 
-	i_vpr_h(inst, "%s: payload[0]: %u payload[1]: %u\n", __func__,
-		alignment_factor[0], alignment_factor[1]);
+	payload[0] = stride_y << 16 | scanline_y;
+	payload[1] = stride_uv << 16 | scanline_uv;
+	i_vpr_h(inst, "%s: stride_y: %d scanline_y: %d "
+		"stride_uv: %d, scanline_uv: %d", __func__,
+		stride_y, scanline_y, stride_uv, scanline_uv);
 	rc = venus_hfi_session_property(inst,
-			HFI_PROP_LINEAR_ALIGNMENT_FACTOR,
+			HFI_PROP_LINEAR_STRIDE_SCANLINE,
 			HFI_HOST_FLAGS_NONE,
 			get_hfi_port(inst, port),
 			HFI_PAYLOAD_64_PACKED,
-			&alignment_factor,
+			&payload,
 			sizeof(u64));
 	if (rc)
 		return rc;
-*/
+
 	return 0;
 }
 
@@ -372,7 +366,7 @@ static int msm_venc_set_input_properties(struct msm_vidc_inst *inst)
 		case HFI_PROP_RAW_RESOLUTION:
 			rc = msm_venc_set_raw_resolution(inst, INPUT_PORT);
 			break;
-		case HFI_PROP_LINEAR_ALIGNMENT_FACTOR:
+		case HFI_PROP_LINEAR_STRIDE_SCANLINE:
 			rc = msm_venc_set_linear_alignment_factor(inst, INPUT_PORT);
 			break;
 		case HFI_PROP_BUFFER_HOST_MAX_COUNT:
@@ -384,8 +378,12 @@ static int msm_venc_set_input_properties(struct msm_vidc_inst *inst)
 			rc = -EINVAL;
 			break;
 		}
+
+		if (rc)
+			goto exit;
 	}
 
+exit:
 	return rc;
 }
 
@@ -418,8 +416,12 @@ static int msm_venc_set_output_properties(struct msm_vidc_inst *inst)
 			rc = -EINVAL;
 			break;
 		}
+
+		if (rc)
+			goto exit;
 	}
 
+exit:
 	return rc;
 }