diff --git a/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c b/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c index 9044ef6aa999d5d901bb1de679520f0a05a264e5..699a944469d58bc63e549a29485e0cddc3c91fd2 100644 --- a/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c +++ b/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c @@ -43,6 +43,8 @@ #define PLUGIN_PUBLIC #endif +#define RK3288_VPU_NAME "rk3288-vpu-enc" +#define HANTRO_VPU_NAME "hantro-vpu" #define DEFAULT_FRAME_RATE 30 #define DEFAULT_BITRATE 1000000 #define PENDING_BUFFER_QUEUE_SIZE VIDEO_MAX_FRAME @@ -92,7 +94,7 @@ struct pending_buffer_queue { * when the parameters to pass together with the source buffer are * ready; those params are received on dequeing the previous * destination buffer. - * @get_param_payload: Payload of V4L2_CID_PRIVATE_ROCKCHIP_GET_PARAMS. This is + * @get_param_payload: Payload of V4L2_CID_PRIVATE_HANTRO_RET_PARAMS. This is * used to update the encoder configuration by * rk_vepu_update_config(). * @get_param_payload_size: The size of get_param_payload. @@ -183,7 +185,7 @@ static struct pending_buffer *queue_back(struct pending_buffer_queue *queue); bool is_rockchip_encoder(int fd); /* Set encoder configuration to the driver. */ int set_encoder_config_locked(struct encoder_context *ctx, int fd, - uint32_t buffer_index, size_t num_ctrls, uint32_t ctrls_ids[], + size_t num_ctrls, uint32_t ctrls_ids[], void **payloads, uint32_t payload_sizes[]); /* QBUF a buffer from the pending buffer queue if it is not empty. */ static int qbuf_if_pending_buffer_exists_locked(struct encoder_context *ctx, @@ -226,7 +228,7 @@ static void *plugin_init(int fd) queue_init(&ctx->pending_buffers); memset(&ext_ctrl, 0, sizeof(ext_ctrl)); - ext_ctrl.id = V4L2_CID_PRIVATE_ROCKCHIP_GET_PARAMS; + ext_ctrl.id = V4L2_CID_PRIVATE_HANTRO_RET_PARAMS; ret = SYS_IOCTL(fd, VIDIOC_QUERY_EXT_CTRL, &ext_ctrl); if (ret) { goto fail; @@ -400,12 +402,11 @@ static int ioctl_qbuf_locked(struct encoder_context *ctx, int fd, return -EIO; } /* Set the encoder configuration to the driver. */ - ret = set_encoder_config_locked(ctx, fd, buffer->index, num_ctrls, ctrl_ids, + ret = set_encoder_config_locked(ctx, fd, num_ctrls, ctrl_ids, payloads, payload_sizes); if (ret) return ret; - buffer->config_store = buffer->index + 1; ret = SYS_IOCTL(fd, VIDIOC_QBUF, buffer); if (ret == 0) ctx->can_qbuf = false; @@ -440,7 +441,7 @@ static int ioctl_dqbuf_locked(struct encoder_context *ctx, int fd, memset(ctx->get_param_payload, 0, ctx->get_param_payload_size); memset(&v4l2_ctrl, 0, sizeof(v4l2_ctrl)); - v4l2_ctrl.id = V4L2_CID_PRIVATE_ROCKCHIP_GET_PARAMS; + v4l2_ctrl.id = V4L2_CID_PRIVATE_HANTRO_RET_PARAMS; v4l2_ctrl.size = ctx->get_param_payload_size; v4l2_ctrl.ptr = ctx->get_param_payload; memset(&ext_ctrls, 0, sizeof(ext_ctrls)); @@ -708,11 +709,12 @@ bool is_rockchip_encoder(int fd) { if (ret) return false; VLOG_FD(1, "driver name return %s\n", (char*)cap.card); - return strstr((const char *)cap.card, "-enc") != NULL; + return strcmp(RK3288_VPU_NAME, (const char *)cap.driver) == 0 || + strcmp(HANTRO_VPU_NAME, (const char *)cap.driver) == 0; } int set_encoder_config_locked(struct encoder_context *ctx, int fd, - uint32_t buffer_index, size_t num_ctrls, uint32_t ctrl_ids[], + size_t num_ctrls, uint32_t ctrl_ids[], void **payloads, uint32_t payload_sizes[]) { size_t i; @@ -727,7 +729,6 @@ int set_encoder_config_locked(struct encoder_context *ctx, int fd, return -EIO; } memset(&ext_ctrls, 0, sizeof(ext_ctrls)); - ext_ctrls.config_store = buffer_index + 1; ext_ctrls.count = num_ctrls; ext_ctrls.controls = ctx->v4l2_ctrls; memset(ctx->v4l2_ctrls, 0, sizeof(ctx->v4l2_ctrls)); @@ -799,6 +800,15 @@ static int initialize_libvpu(struct encoder_context *ctx, int fd) init_param.output_format = format.fmt.pix_mp.pixelformat; /* Get the cropped size. */ +#if 0 + struct v4l2_crop crop; + memset(&crop, 0, sizeof(crop)); + crop.type = ctx->output_streamon_type; + ret = SYS_IOCTL(fd, VIDIOC_G_CROP, &crop); + if (ret) + return ret; +#endif + init_param.width = ctx->crop_width; init_param.height = ctx->crop_height; diff --git a/libv4l-rockchip_v2/libvepu/h264e/h264e.c b/libv4l-rockchip_v2/libvepu/h264e/h264e.c index 847cb6ee4e82d81bc336f92ab3d0ce0f34ad0758..3dbbf89ad086ddd3d1cbba70d99b7a21dda1f474 100644 --- a/libv4l-rockchip_v2/libvepu/h264e/h264e.c +++ b/libv4l-rockchip_v2/libvepu/h264e/h264e.c @@ -490,7 +490,7 @@ static int h264e_init(struct rk_venc *ictx, if (ctx->pps.transform_8x8_mode_flag == 2) ctx->pps.transform_8x8_mode_flag = 1; - ctx->rk_ctrl_ids[0] = V4L2_CID_PRIVATE_ROCKCHIP_REG_PARAMS; + ctx->rk_ctrl_ids[0] = V4L2_CID_PRIVATE_HANTRO_REG_PARAMS; h264e_build_stream_header(ictx); diff --git a/libv4l-rockchip_v2/libvepu/rk_vepu_interface.h b/libv4l-rockchip_v2/libvepu/rk_vepu_interface.h index 31727ea30d9b70a00adb3976402d0f219fda20a8..9e4eb57d0b65a356ca5393b53a92a07aa9b2f18c 100644 --- a/libv4l-rockchip_v2/libvepu/rk_vepu_interface.h +++ b/libv4l-rockchip_v2/libvepu/rk_vepu_interface.h @@ -17,12 +17,11 @@ #include <stddef.h> #include <stdint.h> -/* TODO(wuchengli): Remove these after the header is updated. */ -#define V4L2_CID_CUSTOM_BASE (V4L2_CID_USER_BASE | 0x1000) -#define V4L2_CID_PRIVATE_ROCKCHIP_HEADER (V4L2_CID_CUSTOM_BASE) -#define V4L2_CID_PRIVATE_ROCKCHIP_REG_PARAMS (V4L2_CID_CUSTOM_BASE + 1) -#define V4L2_CID_PRIVATE_ROCKCHIP_HW_PARAMS (V4L2_CID_CUSTOM_BASE + 2) -#define V4L2_CID_PRIVATE_ROCKCHIP_GET_PARAMS (V4L2_CID_CUSTOM_BASE + 3) +#define V4L2_CID_USER_HANTRO_ENCODER_BASE (V4L2_CID_USER_BASE + 0x2000) +#define V4L2_CID_PRIVATE_HANTRO_HEADER (V4L2_CID_USER_HANTRO_ENCODER_BASE + 0) +#define V4L2_CID_PRIVATE_HANTRO_REG_PARAMS (V4L2_CID_USER_HANTRO_ENCODER_BASE + 1) +#define V4L2_CID_PRIVATE_HANTRO_HW_PARAMS (V4L2_CID_USER_HANTRO_ENCODER_BASE + 2) +#define V4L2_CID_PRIVATE_HANTRO_RET_PARAMS (V4L2_CID_USER_HANTRO_ENCODER_BASE + 3) #ifndef V4L2_CID_MPEG_VIDEO_H264_SPS_PPS_BEFORE_IDR #define V4L2_CID_MPEG_VIDEO_H264_SPS_PPS_BEFORE_IDR (V4L2_CID_MPEG_BASE+388) diff --git a/libv4l-rockchip_v2/libvepu/vp8e/vp8e.c b/libv4l-rockchip_v2/libvepu/vp8e/vp8e.c index 80d7a4d2f2a714ab3de97e2306d157c605e9a295..4fc39632ed4791703fbc455202e5a4e88dafb786 100644 --- a/libv4l-rockchip_v2/libvepu/vp8e/vp8e.c +++ b/libv4l-rockchip_v2/libvepu/vp8e/vp8e.c @@ -88,9 +88,9 @@ static int vp8e_init(struct rk_venc *ictx, return -1; } - ctx->rk_ctrl_ids[0] = V4L2_CID_PRIVATE_ROCKCHIP_HEADER; - ctx->rk_ctrl_ids[1] = V4L2_CID_PRIVATE_ROCKCHIP_REG_PARAMS; - ctx->rk_ctrl_ids[2] = V4L2_CID_PRIVATE_ROCKCHIP_HW_PARAMS; + ctx->rk_ctrl_ids[0] = V4L2_CID_PRIVATE_HANTRO_HEADER; + ctx->rk_ctrl_ids[1] = V4L2_CID_PRIVATE_HANTRO_REG_PARAMS; + ctx->rk_ctrl_ids[2] = V4L2_CID_PRIVATE_HANTRO_HW_PARAMS; return 0; }