Camera selection and mode change fixes
This commit is contained in:
30
utility.c
30
utility.c
@@ -92,8 +92,8 @@ struct camera_data {
|
||||
char devnode_path[261];
|
||||
};
|
||||
struct camera_config configurations[] = {
|
||||
{"front", "gc2145", 320, 240, MEDIA_BUS_FMT_UYVY8_2X8, MEDIA_BUS_FMT_SBGGR8_1X8, {1, 15}},
|
||||
{"rear", "ov5640", 1280, 720, MEDIA_BUS_FMT_UYVY8_2X8, MEDIA_BUS_FMT_SBGGR8_1X8, {1, 30}},
|
||||
{"secondary", "gc2145", 1280, 720, MEDIA_BUS_FMT_UYVY8_2X8, MEDIA_BUS_FMT_SBGGR8_1X8, {1, 15}},
|
||||
{"primary", "ov5640", 1280, 720, MEDIA_BUS_FMT_UYVY8_2X8, MEDIA_BUS_FMT_SBGGR8_1X8, {1, 30}},
|
||||
};
|
||||
struct camera_data cam_store[] = {
|
||||
{},
|
||||
@@ -161,10 +161,8 @@ gst_pinesrcbin_get_entity_interface(struct device_data *dev, uint32_t id)
|
||||
{
|
||||
const struct media_v2_link *link =
|
||||
gst_pinesrcbin_get_link_from_entity(dev, id);
|
||||
g_print("entity id: %d\n", id);
|
||||
if (!link)
|
||||
return NULL;
|
||||
g_print("link id: %d %d\n", link->sink_id, link->source_id);
|
||||
return gst_pinesrcbin_get_interface_by_id(dev, link->source_id);
|
||||
}
|
||||
|
||||
@@ -186,9 +184,6 @@ gst_pinesrcbin_find_media_entity(struct device_data *dev,
|
||||
{
|
||||
int length = strlen(driver_name);
|
||||
int i;
|
||||
for (i = 0; i < dev->num_entities; i++)
|
||||
g_print("%s: entity: %s:%d:%s\n", dev->path, dev->entities[i].name,
|
||||
dev->entities[i].id, driver_name);
|
||||
for (i = 0; i < dev->num_entities; i++) {
|
||||
if (!strncmp(dev->entities[i].name, driver_name, length))
|
||||
return &dev->entities[i];
|
||||
@@ -206,7 +201,6 @@ static void disable_all_links(struct device_data *dev)
|
||||
continue;
|
||||
if (!(sink_pad->flags & MEDIA_PAD_FL_SINK))
|
||||
continue;
|
||||
g_print("sink pad: %d\n", sink_pad->id);
|
||||
for (j = 0; j < dev->num_entities; j++) {
|
||||
if (i == j)
|
||||
continue;
|
||||
@@ -214,10 +208,8 @@ static void disable_all_links(struct device_data *dev)
|
||||
gst_pinesrcbin_get_pad_from_entity (dev, dev->entities[j].id);
|
||||
if (!source_pad)
|
||||
continue;
|
||||
g_print("source pad: %d\n", source_pad->id);
|
||||
if (!(source_pad->flags & MEDIA_PAD_FL_SOURCE))
|
||||
continue;
|
||||
g_print("disabling link %d %d\n", source_pad->entity_id, sink_pad->entity_id);
|
||||
setup_link(dev, source_pad->id, sink_pad->id, FALSE);
|
||||
}
|
||||
}
|
||||
@@ -377,7 +369,7 @@ static int alloc_device(struct device_data *dev)
|
||||
rc = xioctl(dev->fd, MEDIA_IOC_G_TOPOLOGY, &dev->topology);
|
||||
if (rc < 0)
|
||||
{
|
||||
g_printerr("topology x1 error %d %d %s\n", rc,
|
||||
g_error("topology x1 error %d %d %s\n", rc,
|
||||
errno, strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
@@ -399,12 +391,10 @@ static int alloc_device(struct device_data *dev)
|
||||
dev->topology.ptr_interfaces = (uint64_t)dev->interfaces;
|
||||
dev->topology.ptr_pads = (uint64_t)dev->pads;
|
||||
dev->topology.ptr_links = (uint64_t)dev->links;
|
||||
g_print("topology x2\n");
|
||||
rc = xioctl(dev->fd, MEDIA_IOC_G_TOPOLOGY, &dev->topology);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
|
||||
g_print("device info\n");
|
||||
rc = xioctl(dev->fd, MEDIA_IOC_DEVICE_INFO, &dev->info);
|
||||
out:
|
||||
return rc;
|
||||
@@ -596,7 +586,7 @@ void gst_pinesrcbin_configure_device(GstPineSrcBin * self, const char *conf_name
|
||||
camera_control (cam_data->subdev_fd, V4L2_CID_FOCUS_AUTO, VIDIOC_S_EXT_CTRLS, &enable);
|
||||
}
|
||||
setup_gain (cam_data->subdev_fd, &cam_data->gain_ctrl, &cam_data->gain_max);
|
||||
self->test_pattern = 1;
|
||||
/* self->test_pattern = 1; */
|
||||
camera_control (cam_data->subdev_fd, V4L2_CID_TEST_PATTERN, VIDIOC_S_EXT_CTRLS, &self->test_pattern);
|
||||
{
|
||||
int auto_gain = 1;
|
||||
@@ -612,3 +602,15 @@ void gst_pinesrcbin_configure_device(GstPineSrcBin * self, const char *conf_name
|
||||
setup_link(self->media_if, cam_data->pad->id, self->v4l2pad->id, TRUE);
|
||||
}
|
||||
|
||||
|
||||
void gst_pinesrcbin_free_device(GstPineSrcBin * self)
|
||||
{
|
||||
struct camera_data *cam_data = get_camera_data(self->device);
|
||||
if (!self->media_if)
|
||||
return;
|
||||
close(cam_data->subdev_fd);
|
||||
close(self->fd);
|
||||
disable_all_links(self->media_if);
|
||||
close(self->media_if);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user