libv4lplugins: Report H264 Main profile only is supported
RK3399 supports H264 Base, Main and High profiles. However,
libv4lplugins support Main profile only. So, in the plugin layer,
it needs to interrupt the IOCTL and report H264 Main profile only
is supported.
BUG=b:145095115
TEST=android.media.cts.MediaRecorderTest#testProfileAvcBaselineLevel1
Change-Id: I6b050c99474a97c535b38ba6896c147728a3be25
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/libv4lplugins/+/1958319
Tested-by: Hirokazu Honda <hiroh@chromium.org>
Auto-Submit: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
diff --git a/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c b/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c
index 46800e5..f579cd5 100644
--- a/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c
+++ b/libv4l-rockchip_v2/libv4l-encplugin-rockchip.c
@@ -162,6 +162,10 @@
struct v4l2_requestbuffers *reqbufs);
static int ioctl_encoder_cmd_locked(struct encoder_context *ctx, int fd,
struct v4l2_encoder_cmd *argp);
+static int ioctl_querymenu_locked(struct encoder_context *ctx, int fd,
+ struct v4l2_querymenu *argp);
+static int ioctl_queryctrl_locked(struct encoder_context *ctx, int fd,
+ struct v4l2_queryctrl *argp);
/* Helper functions to manipulate the pending buffer queue. */
@@ -313,6 +317,14 @@
ret = ioctl_encoder_cmd_locked(ctx, fd, arg);
break;
+ case VIDIOC_QUERYCTRL:
+ ret = ioctl_queryctrl_locked(ctx, fd, arg);
+ break;
+
+ case VIDIOC_QUERYMENU:
+ ret = ioctl_querymenu_locked(ctx, fd, arg);
+ break;
+
default:
ret = SYS_IOCTL(fd, cmd, arg);
break;
@@ -633,6 +645,43 @@
return SYS_IOCTL(fd, VIDIOC_ENCODER_CMD, argp);
}
+static int ioctl_querymenu_locked(struct encoder_context *ctx, int fd,
+ struct v4l2_querymenu *argp)
+{
+
+ if (argp->id == V4L2_CID_MPEG_VIDEO_H264_PROFILE) {
+ /*
+ * Return invalid unless the queried h264 profile is Main. The
+ * hardware supports H264 Base, Main, High profile, but this
+ * plugin supports Main profile only because Main profile is
+ * hard-coded in h264e_init_sps().
+ */
+ if (argp->index == V4L2_MPEG_VIDEO_H264_PROFILE_MAIN)
+ return 0;
+ return -EINVAL;
+ }
+ return SYS_IOCTL(fd, VIDIOC_QUERYMENU, argp);
+}
+
+static int ioctl_queryctrl_locked(struct encoder_context *ctx, int fd,
+ struct v4l2_queryctrl *argp)
+{
+ if (argp->id == V4L2_CID_MPEG_VIDEO_H264_PROFILE) {
+ /*
+ * Filter out other H264 profiles than Main profile. The
+ * hardware supports H264 Base, Main, High profile, but this
+ * plugin supports Main profile only because Main profile is
+ * hard-coded in h264e_init_sps().
+ */
+ argp->type = V4L2_CTRL_TYPE_MENU;
+ argp->minimum = argp->maximum = argp->default_value =
+ V4L2_MPEG_VIDEO_H264_PROFILE_MAIN;
+ argp->step = 1;
+ return 0;
+ }
+ return SYS_IOCTL(fd, VIDIOC_QUERYMENU, argp);
+}
+
bool is_rockchip_encoder(int fd) {
struct v4l2_capability cap;
memset(&cap, 0, sizeof(cap));
@@ -863,6 +912,10 @@
return "VIDIOC_QUERYBUF";
case VIDIOC_ENCODER_CMD:
return "VIDIOC_ENCODER_CMD";
+ case VIDIOC_QUERYMENU:
+ return "VIDIOC_QUERYMENU";
+ case VIDIOC_QUERYCTRL:
+ return "VIDIOC_QUERYCTRL";
default:
return "UNKNOWN";
}