1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-12 13:44:56 +02:00

If the v4l2 driver supports the extended control api, use it to enumerate all the controls when the ControlReset function is called (it will reset all the controls which aren't in the MPEG class), else fallback to the old api.

This commit is contained in:
Antoine Cellerier 2008-01-13 15:04:04 +00:00
parent 827f8b92b5
commit d372e0d833

View File

@ -3310,9 +3310,41 @@ static int ControlReset( vlc_object_t *p_obj, int i_fd )
{
struct v4l2_queryctrl queryctrl;
int i_cid;
memset( &queryctrl, 0, sizeof( queryctrl ) );
queryctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
if( ioctl( i_fd, VIDIOC_QUERYCTRL, &queryctrl ) >= 0 )
{
/* Extended control API supported */
queryctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
while( ioctl( i_fd, VIDIOC_QUERYCTRL, &queryctrl ) >= 0 )
{
if( queryctrl.type == V4L2_CTRL_TYPE_CTRL_CLASS
|| V4L2_CTRL_ID2CLASS( queryctrl.id ) == V4L2_CTRL_CLASS_MPEG )
{
queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
continue;
}
struct v4l2_control control;
memset( &control, 0, sizeof( control ) );
control.id = queryctrl.id;
if( ioctl( i_fd, VIDIOC_G_CTRL, &control ) >= 0
&& queryctrl.default_value != control.value )
{
int i;
for( i = 0; controls[i].psz_name != NULL; i++ )
if( controls[i].i_cid == queryctrl.id ) break;
Control( p_obj, i_fd,
controls[i].psz_name ? controls[i].psz_name
: (const char *)queryctrl.name,
queryctrl.id, queryctrl.default_value );
}
queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
}
}
else
{
/* public controls */
for( i_cid = V4L2_CID_BASE;
i_cid < V4L2_CID_LASTP1;
@ -3363,6 +3395,7 @@ static int ControlReset( vlc_object_t *p_obj, int i_fd )
else
break;
}
}
return VLC_SUCCESS;
}