video: driver: request api fixes for v4l2-compliance
- add support for prepare_buf - check if client has configured invalid fd for metadata buffer fd control. Change-Id: I576d02be05e4692a5ab45286895c34284f08651c Signed-off-by: Darshana Patil <darshana@quicinc.com>
This commit is contained in:
@@ -1616,7 +1616,7 @@ static struct msm_platform_inst_capability instance_data_kalama[] = {
|
|||||||
msm_vidc_adjust_all_intra, NULL},
|
msm_vidc_adjust_all_intra, NULL},
|
||||||
|
|
||||||
{INPUT_METADATA_FD, ENC|DEC, CODECS_ALL,
|
{INPUT_METADATA_FD, ENC|DEC, CODECS_ALL,
|
||||||
-1, INT_MAX, 1, -1,
|
INVALID_FD, INT_MAX, 1, INVALID_FD,
|
||||||
V4L2_CID_MPEG_VIDC_INPUT_METADATA_FD,
|
V4L2_CID_MPEG_VIDC_INPUT_METADATA_FD,
|
||||||
0,
|
0,
|
||||||
CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
|
CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
|
||||||
|
@@ -1474,7 +1474,7 @@ static struct msm_platform_inst_capability instance_data_waipio[] = {
|
|||||||
msm_vidc_adjust_all_intra, NULL},
|
msm_vidc_adjust_all_intra, NULL},
|
||||||
|
|
||||||
{INPUT_METADATA_FD, ENC|DEC, CODECS_ALL,
|
{INPUT_METADATA_FD, ENC|DEC, CODECS_ALL,
|
||||||
-1, INT_MAX, 1, -1,
|
INVALID_FD, INT_MAX, 1, INVALID_FD,
|
||||||
V4L2_CID_MPEG_VIDC_INPUT_METADATA_FD,
|
V4L2_CID_MPEG_VIDC_INPUT_METADATA_FD,
|
||||||
0,
|
0,
|
||||||
CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
|
CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
|
||||||
|
@@ -28,6 +28,8 @@ int msm_vidc_g_param(void *instance, struct v4l2_streamparm *sp);
|
|||||||
int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
|
int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
|
||||||
int msm_vidc_querybuf(void *instance, struct v4l2_buffer *b);
|
int msm_vidc_querybuf(void *instance, struct v4l2_buffer *b);
|
||||||
int msm_vidc_create_bufs(void *instance, struct v4l2_create_buffers *b);
|
int msm_vidc_create_bufs(void *instance, struct v4l2_create_buffers *b);
|
||||||
|
int msm_vidc_prepare_buf(void *instance, struct media_device *mdev,
|
||||||
|
struct v4l2_buffer *b);
|
||||||
int msm_vidc_release_buffer(void *instance, int buffer_type,
|
int msm_vidc_release_buffer(void *instance, int buffer_type,
|
||||||
unsigned int buffer_index);
|
unsigned int buffer_index);
|
||||||
int msm_vidc_qbuf(void *instance, struct media_device *mdev,
|
int msm_vidc_qbuf(void *instance, struct media_device *mdev,
|
||||||
|
@@ -450,7 +450,7 @@ bool res_is_less_than(u32 width, u32 height,
|
|||||||
bool res_is_less_than_or_equal_to(u32 width, u32 height,
|
bool res_is_less_than_or_equal_to(u32 width, u32 height,
|
||||||
u32 ref_width, u32 ref_height);
|
u32 ref_width, u32 ref_height);
|
||||||
int msm_vidc_get_properties(struct msm_vidc_inst *inst);
|
int msm_vidc_get_properties(struct msm_vidc_inst *inst);
|
||||||
int msm_vidc_create_input_metadata_buffer(struct msm_vidc_inst *inst, u32 buf_fd);
|
int msm_vidc_create_input_metadata_buffer(struct msm_vidc_inst *inst, int buf_fd);
|
||||||
int msm_vidc_update_input_meta_buffer_index(struct msm_vidc_inst *inst, struct vb2_buffer *vb2);
|
int msm_vidc_update_input_meta_buffer_index(struct msm_vidc_inst *inst, struct vb2_buffer *vb2);
|
||||||
#endif // _MSM_VIDC_DRIVER_H_
|
#endif // _MSM_VIDC_DRIVER_H_
|
||||||
|
|
||||||
|
@@ -38,6 +38,8 @@ int msm_v4l2_querybuf(struct file *file, void *fh,
|
|||||||
struct v4l2_buffer *b);
|
struct v4l2_buffer *b);
|
||||||
int msm_v4l2_create_bufs(struct file *filp, void *fh,
|
int msm_v4l2_create_bufs(struct file *filp, void *fh,
|
||||||
struct v4l2_create_buffers *b);
|
struct v4l2_create_buffers *b);
|
||||||
|
int msm_v4l2_prepare_buf(struct file *filp, void *fh,
|
||||||
|
struct v4l2_buffer *b);
|
||||||
int msm_v4l2_qbuf(struct file *file, void *fh,
|
int msm_v4l2_qbuf(struct file *file, void *fh,
|
||||||
struct v4l2_buffer *b);
|
struct v4l2_buffer *b);
|
||||||
int msm_v4l2_dqbuf(struct file *file, void *fh,
|
int msm_v4l2_dqbuf(struct file *file, void *fh,
|
||||||
|
@@ -474,6 +474,35 @@ exit:
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(msm_vidc_create_bufs);
|
EXPORT_SYMBOL(msm_vidc_create_bufs);
|
||||||
|
|
||||||
|
int msm_vidc_prepare_buf(void *instance, struct media_device *mdev,
|
||||||
|
struct v4l2_buffer *b)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
struct msm_vidc_inst *inst = instance;
|
||||||
|
struct vb2_queue *q;
|
||||||
|
|
||||||
|
if (!inst || !inst->core || !b || !valid_v4l2_buffer(b, inst)) {
|
||||||
|
d_vpr_e("%s: invalid params %pK %pK\n", __func__, inst, b);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
q = msm_vidc_get_vb2q(inst, b->type, __func__);
|
||||||
|
if (!q) {
|
||||||
|
rc = -EINVAL;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = vb2_prepare_buf(q, mdev, b);
|
||||||
|
if (rc) {
|
||||||
|
i_vpr_e(inst, "%s: failed with %d\n", __func__, rc);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(msm_vidc_prepare_buf);
|
||||||
|
|
||||||
int msm_vidc_qbuf(void *instance, struct media_device *mdev,
|
int msm_vidc_qbuf(void *instance, struct media_device *mdev,
|
||||||
struct v4l2_buffer *b)
|
struct v4l2_buffer *b)
|
||||||
{
|
{
|
||||||
|
@@ -1102,6 +1102,12 @@ int msm_v4l2_op_s_ctrl(struct v4l2_ctrl *ctrl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctrl->id == V4L2_CID_MPEG_VIDC_INPUT_METADATA_FD) {
|
if (ctrl->id == V4L2_CID_MPEG_VIDC_INPUT_METADATA_FD) {
|
||||||
|
if (ctrl->val == INVALID_FD || ctrl->val == INT_MAX) {
|
||||||
|
i_vpr_e(inst,
|
||||||
|
"%s: client configured invalid input metadata fd %d\n",
|
||||||
|
__func__, ctrl->val);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!capability->cap[INPUT_META_VIA_REQUEST].value) {
|
if (!capability->cap[INPUT_META_VIA_REQUEST].value) {
|
||||||
i_vpr_e(inst,
|
i_vpr_e(inst,
|
||||||
"%s: input metadata not enabled via request\n", __func__);
|
"%s: input metadata not enabled via request\n", __func__);
|
||||||
|
@@ -6270,7 +6270,7 @@ int msm_vidc_get_properties(struct msm_vidc_inst *inst)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int msm_vidc_create_input_metadata_buffer(struct msm_vidc_inst *inst, u32 fd)
|
int msm_vidc_create_input_metadata_buffer(struct msm_vidc_inst *inst, int fd)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
struct msm_vidc_buffer *buf = NULL;
|
struct msm_vidc_buffer *buf = NULL;
|
||||||
@@ -6282,7 +6282,7 @@ int msm_vidc_create_input_metadata_buffer(struct msm_vidc_inst *inst, u32 fd)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fd <= 0) {
|
if (fd < 0) {
|
||||||
i_vpr_e(inst, "%s: invalid input metadata buffer fd %d\n",
|
i_vpr_e(inst, "%s: invalid input metadata buffer fd %d\n",
|
||||||
__func__, fd);
|
__func__, fd);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@@ -62,6 +62,7 @@ static struct v4l2_ioctl_ops msm_v4l2_ioctl_ops_enc = {
|
|||||||
.vidioc_reqbufs = msm_v4l2_reqbufs,
|
.vidioc_reqbufs = msm_v4l2_reqbufs,
|
||||||
.vidioc_querybuf = msm_v4l2_querybuf,
|
.vidioc_querybuf = msm_v4l2_querybuf,
|
||||||
.vidioc_create_bufs = msm_v4l2_create_bufs,
|
.vidioc_create_bufs = msm_v4l2_create_bufs,
|
||||||
|
.vidioc_prepare_buf = msm_v4l2_prepare_buf,
|
||||||
.vidioc_qbuf = msm_v4l2_qbuf,
|
.vidioc_qbuf = msm_v4l2_qbuf,
|
||||||
.vidioc_dqbuf = msm_v4l2_dqbuf,
|
.vidioc_dqbuf = msm_v4l2_dqbuf,
|
||||||
.vidioc_streamon = msm_v4l2_streamon,
|
.vidioc_streamon = msm_v4l2_streamon,
|
||||||
@@ -101,6 +102,7 @@ static struct v4l2_ioctl_ops msm_v4l2_ioctl_ops_dec = {
|
|||||||
.vidioc_reqbufs = msm_v4l2_reqbufs,
|
.vidioc_reqbufs = msm_v4l2_reqbufs,
|
||||||
.vidioc_querybuf = msm_v4l2_querybuf,
|
.vidioc_querybuf = msm_v4l2_querybuf,
|
||||||
.vidioc_create_bufs = msm_v4l2_create_bufs,
|
.vidioc_create_bufs = msm_v4l2_create_bufs,
|
||||||
|
.vidioc_prepare_buf = msm_v4l2_prepare_buf,
|
||||||
.vidioc_qbuf = msm_v4l2_qbuf,
|
.vidioc_qbuf = msm_v4l2_qbuf,
|
||||||
.vidioc_dqbuf = msm_v4l2_dqbuf,
|
.vidioc_dqbuf = msm_v4l2_dqbuf,
|
||||||
.vidioc_streamon = msm_v4l2_streamon,
|
.vidioc_streamon = msm_v4l2_streamon,
|
||||||
|
@@ -371,6 +371,31 @@ unlock:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int msm_v4l2_prepare_buf(struct file *filp, void *fh,
|
||||||
|
struct v4l2_buffer *b)
|
||||||
|
{
|
||||||
|
struct msm_vidc_inst *inst = get_vidc_inst(filp, fh);
|
||||||
|
struct video_device *vdev = video_devdata(filp);
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
inst = get_inst_ref(g_core, inst);
|
||||||
|
if (!inst) {
|
||||||
|
d_vpr_e("%s: invalid instance\n", __func__);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
inst_lock(inst, __func__);
|
||||||
|
rc = msm_vidc_prepare_buf((void *)inst, vdev->v4l2_dev->mdev, b);
|
||||||
|
if (rc)
|
||||||
|
goto unlock;
|
||||||
|
|
||||||
|
unlock:
|
||||||
|
inst_unlock(inst, __func__);
|
||||||
|
put_inst(inst);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
int msm_v4l2_qbuf(struct file *filp, void *fh,
|
int msm_v4l2_qbuf(struct file *filp, void *fh,
|
||||||
struct v4l2_buffer *b)
|
struct v4l2_buffer *b)
|
||||||
{
|
{
|
||||||
@@ -748,17 +773,19 @@ unlock:
|
|||||||
|
|
||||||
int msm_v4l2_request_validate(struct media_request *req)
|
int msm_v4l2_request_validate(struct media_request *req)
|
||||||
{
|
{
|
||||||
|
d_vpr_l("%s()\n", __func__);
|
||||||
return vb2_request_validate(req);
|
return vb2_request_validate(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
void msm_v4l2_request_queue(struct media_request *req)
|
void msm_v4l2_request_queue(struct media_request *req)
|
||||||
{
|
{
|
||||||
|
d_vpr_l("%s()\n", __func__);
|
||||||
v4l2_m2m_request_queue(req);
|
v4l2_m2m_request_queue(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
void msm_v4l2_m2m_device_run(void *priv)
|
void msm_v4l2_m2m_device_run(void *priv)
|
||||||
{
|
{
|
||||||
d_vpr_l("%s: \n", __func__);
|
d_vpr_l("%s()\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void msm_v4l2_m2m_job_abort(void *priv)
|
void msm_v4l2_m2m_job_abort(void *priv)
|
||||||
|
Reference in New Issue
Block a user