video: Make v4l2_ops_s to support the mutilple context

which is useful in the m2m usage scenario, by replacing the first
argument of callback from "struct v4l2_ops_s *" to "struct file *"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2024-03-17 17:04:54 +08:00
committed by Xiang Xiao
parent c6821c741d
commit 79f834dcbb
3 changed files with 213 additions and 193 deletions
+135 -113
View File
File diff suppressed because it is too large Load Diff
+39 -41
View File
@@ -142,7 +142,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->querycap(v4l2,
return v4l2->vops->querycap(filep,
(FAR struct v4l2_capability *)arg);
case VIDIOC_G_INPUT:
@@ -159,7 +159,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->enum_input(v4l2,
return v4l2->vops->enum_input(filep,
(FAR struct v4l2_input *)arg);
case VIDIOC_REQBUFS:
@@ -168,7 +168,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->reqbufs(v4l2,
return v4l2->vops->reqbufs(filep,
(FAR struct v4l2_requestbuffers *)arg);
case VIDIOC_QUERYBUF:
@@ -177,7 +177,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->querybuf(v4l2,
return v4l2->vops->querybuf(filep,
(FAR struct v4l2_buffer *)arg);
case VIDIOC_QBUF:
@@ -186,7 +186,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->qbuf(v4l2,
return v4l2->vops->qbuf(filep,
(FAR struct v4l2_buffer *)arg);
break;
@@ -196,9 +196,8 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->dqbuf(v4l2,
(FAR struct v4l2_buffer *)arg,
filep->f_oflags);
return v4l2->vops->dqbuf(filep,
(FAR struct v4l2_buffer *)arg);
case VIDIOC_CANCEL_DQBUF:
if (v4l2->vops->cancel_dqbuf == NULL)
@@ -206,7 +205,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->cancel_dqbuf(v4l2,
return v4l2->vops->cancel_dqbuf(filep,
(FAR enum v4l2_buf_type)arg);
case VIDIOC_STREAMON:
@@ -215,7 +214,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->streamon(v4l2,
return v4l2->vops->streamon(filep,
(FAR enum v4l2_buf_type *)arg);
case VIDIOC_STREAMOFF:
@@ -224,7 +223,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->streamoff(v4l2,
return v4l2->vops->streamoff(filep,
(FAR enum v4l2_buf_type *)arg);
case VIDIOC_DO_HALFPUSH:
@@ -233,7 +232,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->do_halfpush(v4l2, arg);
return v4l2->vops->do_halfpush(filep, arg);
case VIDIOC_TAKEPICT_START:
if (v4l2->vops->takepict_start == NULL)
@@ -241,7 +240,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->takepict_start(v4l2, (int32_t)arg);
return v4l2->vops->takepict_start(filep, (int32_t)arg);
case VIDIOC_TAKEPICT_STOP:
if (v4l2->vops->takepict_stop == NULL)
@@ -249,7 +248,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->takepict_stop(v4l2, arg);
return v4l2->vops->takepict_stop(filep, arg);
case VIDIOC_S_SELECTION:
if (v4l2->vops->s_selection == NULL)
@@ -257,7 +256,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->s_selection(v4l2,
return v4l2->vops->s_selection(filep,
(FAR struct v4l2_selection *)arg);
case VIDIOC_G_SELECTION:
@@ -266,7 +265,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->g_selection(v4l2,
return v4l2->vops->g_selection(filep,
(FAR struct v4l2_selection *)arg);
case VIDIOC_TRY_FMT:
@@ -275,7 +274,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->try_fmt(v4l2,
return v4l2->vops->try_fmt(filep,
(FAR struct v4l2_format *)arg);
case VIDIOC_G_FMT:
@@ -284,7 +283,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->g_fmt(v4l2,
return v4l2->vops->g_fmt(filep,
(FAR struct v4l2_format *)arg);
case VIDIOC_S_FMT:
@@ -293,7 +292,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->s_fmt(v4l2,
return v4l2->vops->s_fmt(filep,
(FAR struct v4l2_format *)arg);
case VIDIOC_S_PARM:
@@ -302,7 +301,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->s_parm(v4l2,
return v4l2->vops->s_parm(filep,
(FAR struct v4l2_streamparm *)arg);
case VIDIOC_G_PARM:
@@ -311,7 +310,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->g_parm(v4l2,
return v4l2->vops->g_parm(filep,
(FAR struct v4l2_streamparm *)arg);
case VIDIOC_QUERYCTRL:
@@ -320,7 +319,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->queryctrl(v4l2,
return v4l2->vops->queryctrl(filep,
(FAR struct v4l2_queryctrl *)arg);
case VIDIOC_QUERY_EXT_CTRL:
@@ -329,7 +328,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->query_ext_ctrl(v4l2,
return v4l2->vops->query_ext_ctrl(filep,
(FAR struct v4l2_query_ext_ctrl *)arg);
case VIDIOC_QUERYMENU:
@@ -338,7 +337,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->querymenu(v4l2,
return v4l2->vops->querymenu(filep,
(FAR struct v4l2_querymenu *)arg);
case VIDIOC_G_CTRL:
@@ -347,7 +346,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->g_ctrl(v4l2,
return v4l2->vops->g_ctrl(filep,
(FAR struct v4l2_control *)arg);
case VIDIOC_S_CTRL:
@@ -356,7 +355,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->s_ctrl(v4l2,
return v4l2->vops->s_ctrl(filep,
(FAR struct v4l2_control *)arg);
case VIDIOC_G_EXT_CTRLS:
@@ -365,7 +364,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->g_ext_ctrls(v4l2,
return v4l2->vops->g_ext_ctrls(filep,
(FAR struct v4l2_ext_controls *)arg);
case VIDIOC_S_EXT_CTRLS:
@@ -374,7 +373,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->s_ext_ctrls(v4l2,
return v4l2->vops->s_ext_ctrls(filep,
(FAR struct v4l2_ext_controls *)arg);
case VIDIOC_G_STD:
@@ -389,7 +388,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->query_ext_ctrl_scene(v4l2,
return v4l2->vops->query_ext_ctrl_scene(filep,
(FAR struct v4s_query_ext_ctrl_scene *)arg);
case V4SIOC_QUERYMENU_SCENE:
@@ -398,7 +397,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->querymenu_scene(v4l2,
return v4l2->vops->querymenu_scene(filep,
(FAR struct v4s_querymenu_scene *)arg);
case V4SIOC_G_EXT_CTRLS_SCENE:
@@ -407,7 +406,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->g_ext_ctrls_scene(v4l2,
return v4l2->vops->g_ext_ctrls_scene(filep,
(FAR struct v4s_ext_controls_scene *)arg);
case V4SIOC_S_EXT_CTRLS_SCENE:
@@ -416,7 +415,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->s_ext_ctrls_scene(v4l2,
return v4l2->vops->s_ext_ctrls_scene(filep,
(FAR struct v4s_ext_controls_scene *)arg);
case VIDIOC_ENUM_FMT:
@@ -425,7 +424,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->enum_fmt(v4l2,
return v4l2->vops->enum_fmt(filep,
(FAR struct v4l2_fmtdesc *)arg);
case VIDIOC_ENUM_FRAMEINTERVALS:
@@ -434,7 +433,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->enum_frminterval(v4l2,
return v4l2->vops->enum_frminterval(filep,
(FAR struct v4l2_frmivalenum *)arg);
case VIDIOC_ENUM_FRAMESIZES:
@@ -443,7 +442,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->enum_frmsize(v4l2,
return v4l2->vops->enum_frmsize(filep,
(FAR struct v4l2_frmsizeenum *)arg);
case VIDIOC_CROPCAP:
@@ -452,7 +451,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->cropcap(v4l2,
return v4l2->vops->cropcap(filep,
(FAR struct v4l2_cropcap *)arg);
case VIDIOC_DQEVENT:
@@ -461,7 +460,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->dqevent(v4l2,
return v4l2->vops->dqevent(filep,
(FAR struct v4l2_event *)arg);
case VIDIOC_SUBSCRIBE_EVENT:
@@ -470,7 +469,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->subscribe_event(v4l2,
return v4l2->vops->subscribe_event(filep,
(FAR struct v4l2_event_subscription *)arg);
case VIDIOC_DECODER_CMD:
@@ -479,7 +478,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->decoder_cmd(v4l2,
return v4l2->vops->decoder_cmd(filep,
(FAR struct v4l2_decoder_cmd *)arg);
case VIDIOC_ENCODER_CMD:
@@ -488,7 +487,7 @@ static int v4l2_ioctl(FAR struct file *filep,
break;
}
return v4l2->vops->encoder_cmd(v4l2,
return v4l2->vops->encoder_cmd(filep,
(FAR struct v4l2_encoder_cmd *)arg);
default:
@@ -572,4 +571,3 @@ int video_unregister(FAR const char *devpath)
{
return unregister_driver(devpath);
}
+39 -39
View File
@@ -77,82 +77,82 @@ struct v4l2_s
struct v4l2_ops_s
{
CODE int (*querycap)(FAR struct v4l2_s *ctx,
CODE int (*querycap)(FAR struct file *filep,
FAR struct v4l2_capability *cap);
CODE int (*g_input)(FAR int *num);
CODE int (*enum_input)(FAR struct v4l2_s *ctx,
CODE int (*enum_input)(FAR struct file *filep,
FAR struct v4l2_input *input);
CODE int (*reqbufs)(FAR struct v4l2_s *ctx,
CODE int (*reqbufs)(FAR struct file *filep,
FAR struct v4l2_requestbuffers *reqbufs);
CODE int (*querybuf)(FAR struct v4l2_s *ctx,
CODE int (*querybuf)(FAR struct file *filep,
FAR struct v4l2_buffer *buf);
CODE int (*qbuf)(FAR struct v4l2_s *ctx,
CODE int (*qbuf)(FAR struct file *filep,
FAR struct v4l2_buffer *buf);
CODE int (*dqbuf)(FAR struct v4l2_s *ctx,
FAR struct v4l2_buffer *buf, int oflags);
CODE int (*cancel_dqbuf)(FAR struct v4l2_s *ctx,
CODE int (*dqbuf)(FAR struct file *filep,
FAR struct v4l2_buffer *buf);
CODE int (*cancel_dqbuf)(FAR struct file *filep,
enum v4l2_buf_type type);
CODE int (*g_fmt)(FAR struct v4l2_s *ctx,
CODE int (*g_fmt)(FAR struct file *filep,
FAR struct v4l2_format *fmt);
CODE int (*s_fmt)(FAR struct v4l2_s *ctx,
CODE int (*s_fmt)(FAR struct file *filep,
FAR struct v4l2_format *fmt);
CODE int (*try_fmt)(FAR struct v4l2_s *ctx,
CODE int (*try_fmt)(FAR struct file *filep,
FAR struct v4l2_format *v4l2);
CODE int (*g_parm)(FAR struct v4l2_s *ctx,
CODE int (*g_parm)(FAR struct file *filep,
FAR struct v4l2_streamparm *parm);
CODE int (*s_parm)(FAR struct v4l2_s *ctx,
CODE int (*s_parm)(FAR struct file *filep,
FAR struct v4l2_streamparm *parm);
CODE int (*streamon)(FAR struct v4l2_s *ctx,
CODE int (*streamon)(FAR struct file *filep,
FAR enum v4l2_buf_type *type);
CODE int (*streamoff)(FAR struct v4l2_s *ctx,
CODE int (*streamoff)(FAR struct file *filep,
FAR enum v4l2_buf_type *type);
CODE int (*do_halfpush)(FAR struct v4l2_s *ctx,
CODE int (*do_halfpush)(FAR struct file *filep,
bool enable);
CODE int (*takepict_start)(FAR struct v4l2_s *ctx,
CODE int (*takepict_start)(FAR struct file *filep,
int32_t capture_num);
CODE int (*takepict_stop)(FAR struct v4l2_s *ctx,
CODE int (*takepict_stop)(FAR struct file *filep,
bool halfpush);
CODE int (*s_selection)(FAR struct v4l2_s *ctx,
CODE int (*s_selection)(FAR struct file *filep,
FAR struct v4l2_selection *clip);
CODE int (*g_selection)(FAR struct v4l2_s *ctx,
CODE int (*g_selection)(FAR struct file *filep,
FAR struct v4l2_selection *clip);
CODE int (*queryctrl)(FAR struct v4l2_s *ctx,
CODE int (*queryctrl)(FAR struct file *filep,
FAR struct v4l2_queryctrl *ctrl);
CODE int (*query_ext_ctrl)(FAR struct v4l2_s *ctx,
CODE int (*query_ext_ctrl)(FAR struct file *filep,
FAR struct v4l2_query_ext_ctrl *ctrl);
CODE int (*querymenu)(FAR struct v4l2_s *ctx,
CODE int (*querymenu)(FAR struct file *filep,
FAR struct v4l2_querymenu *menu);
CODE int (*g_ctrl)(FAR struct v4l2_s *ctx,
CODE int (*g_ctrl)(FAR struct file *filep,
FAR struct v4l2_control *ctrl);
CODE int (*s_ctrl)(FAR struct v4l2_s *ctx,
CODE int (*s_ctrl)(FAR struct file *filep,
FAR struct v4l2_control *ctrl);
CODE int (*g_ext_ctrls)(FAR struct v4l2_s *ctx,
CODE int (*g_ext_ctrls)(FAR struct file *filep,
FAR struct v4l2_ext_controls *ctrls);
CODE int (*s_ext_ctrls)(FAR struct v4l2_s *ctx,
CODE int (*s_ext_ctrls)(FAR struct file *filep,
FAR struct v4l2_ext_controls *ctrls);
CODE int (*query_ext_ctrl_scene)(FAR struct v4l2_s *ctx,
CODE int (*query_ext_ctrl_scene)(FAR struct file *filep,
FAR struct v4s_query_ext_ctrl_scene *ctrl);
CODE int (*querymenu_scene)(FAR struct v4l2_s *ctx,
CODE int (*querymenu_scene)(FAR struct file *filep,
FAR struct v4s_querymenu_scene *menu);
CODE int (*g_ext_ctrls_scene)(FAR struct v4l2_s *ctx,
CODE int (*g_ext_ctrls_scene)(FAR struct file *filep,
FAR struct v4s_ext_controls_scene *ctrls);
CODE int (*s_ext_ctrls_scene)(FAR struct v4l2_s *ctx,
CODE int (*s_ext_ctrls_scene)(FAR struct file *filep,
FAR struct v4s_ext_controls_scene *ctrls);
CODE int (*enum_fmt)(FAR struct v4l2_s *ctx,
CODE int (*enum_fmt)(FAR struct file *filep,
FAR struct v4l2_fmtdesc *f);
CODE int (*enum_frminterval)(FAR struct v4l2_s *ctx,
CODE int (*enum_frminterval)(FAR struct file *filep,
FAR struct v4l2_frmivalenum *f);
CODE int (*enum_frmsize)(FAR struct v4l2_s *ctx,
CODE int (*enum_frmsize)(FAR struct file *filep,
FAR struct v4l2_frmsizeenum *f);
CODE int (*cropcap)(FAR struct v4l2_s *ctx,
CODE int (*cropcap)(FAR struct file *filep,
FAR struct v4l2_cropcap *cropcap);
CODE int (*dqevent)(FAR struct v4l2_s *ctx,
CODE int (*dqevent)(FAR struct file *filep,
FAR struct v4l2_event *event);
CODE int (*subscribe_event)(FAR struct v4l2_s *ctx,
CODE int (*subscribe_event)(FAR struct file *filep,
FAR struct v4l2_event_subscription *sub);
CODE int (*decoder_cmd)(FAR struct v4l2_s *ctx,
CODE int (*decoder_cmd)(FAR struct file *filep,
FAR struct v4l2_decoder_cmd *cmd);
CODE int (*encoder_cmd)(FAR struct v4l2_s *ctx,
CODE int (*encoder_cmd)(FAR struct file *filep,
FAR struct v4l2_encoder_cmd *cmd);
};