mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-29 11:40:38 +00:00
cam: Allow time for CA to initialize
Some devices take some time to initialize, and until they are they will error out when trying to get information about the CA device.
This commit is contained in:
parent
25cb359ddb
commit
7a72c961de
1 changed files with 22 additions and 7 deletions
|
@ -104,6 +104,7 @@ cam_device_open (CamDevice * device, const char *filename)
|
|||
ca_caps_t ca_caps;
|
||||
int ret;
|
||||
int i;
|
||||
int count = 10;
|
||||
|
||||
g_return_val_if_fail (device != NULL, FALSE);
|
||||
g_return_val_if_fail (device->state == CAM_DEVICE_STATE_CLOSED, FALSE);
|
||||
|
@ -117,11 +118,15 @@ cam_device_open (CamDevice * device, const char *filename)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
GST_DEBUG ("Successfully opened device %s", filename);
|
||||
|
||||
device->fd = ret;
|
||||
|
||||
ret = ioctl (device->fd, CA_RESET);
|
||||
sleep (1);
|
||||
|
||||
g_usleep (G_USEC_PER_SEC / 10);
|
||||
|
||||
while (TRUE) {
|
||||
/* get the capabilities of the CA */
|
||||
ret = ioctl (device->fd, CA_GET_CAP, &ca_caps);
|
||||
if (ret == -1) {
|
||||
|
@ -129,6 +134,16 @@ cam_device_open (CamDevice * device, const char *filename)
|
|||
reset_state (device);
|
||||
return FALSE;
|
||||
}
|
||||
if (ca_caps.slot_num > 0)
|
||||
break;
|
||||
if (!count) {
|
||||
GST_ERROR ("CA_GET_CAP succeeded but not slots");
|
||||
reset_state (device);
|
||||
return FALSE;
|
||||
}
|
||||
count--;
|
||||
g_usleep (G_USEC_PER_SEC / 5);
|
||||
}
|
||||
|
||||
device->tl = cam_tl_new (device->fd);
|
||||
device->sl = cam_sl_new (device->tl);
|
||||
|
|
Loading…
Reference in a new issue