* [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera
@ 2015-02-26 15:59 Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 01/14] mediactl: Introduce v4l2_subdev structure Jacek Anaszewski
` (14 more replies)
0 siblings, 15 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
This is a fifth version of the patch series adding a plugin for the
Exynos4 camera.
Temporarily the plugin doesn't link against libmediactl, but
has its sources compiled in. Currently utils are built after
the plugins, but libv4l-exynos4-camera plugin depends on the utils.
In order to link the plugin against libmediactl the build system
would have to be modified.
================
Changes from v4:
================
- removed some redundant functions for traversing media device graph
and switched over to using existing ones
- avoided accessing struct v4l2_subdev from libmediactl
- applied various improvements
================
Changes from v3:
================
- added struct v4l2_subdev and put entity fd and
information about supported controls to it
- improved functions for negotiating and setting
pipeline format by using available libv4lsubdev API
- applied minor improvements and cleanups
================
Changes from v2:
================
- switched to using mediatext library for parsing
the media device configuration
- extended libmediactl
- switched to using libmediactl
================
Changes from v1:
================
- removed redundant mbus code negotiation
- split the parser, media device helpers and ioctl wrappers
to the separate modules
- added mechanism for querying extended controls
- applied various fixes and modifications
The plugin was tested on linux-next_20150223 with patches for
exynos4-is that fix failing open ioctl when a sensor sub-device is not
linked [1] [2] [3].
The plugin expects a configuration file:
/var/lib/libv4l/exynos4_capture_conf
Exemplary configuration file:
==========================================
link-conf "s5p-mipi-csis.0":1 -> "FIMC.0":0 [1]
ctrl-to-subdev-conf 0x0098091f -> "fimc.0.capture"
ctrl-to-subdev-conf 0x00980902 -> "S5C73M3"
ctrl-to-subdev-conf 0x00980922 -> "fimc.0.capture"
ctrl-to-subdev-conf 0x009a0914 -> "S5C73M3"
==========================================
With this settings the plugin can be tested on the exynos4412-trats2 board
using following gstreamer pipeline:
gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=960,height=720 ! fbdevsink
Thanks,
Jacek Anaszewski
[1] https://patchwork.linuxtv.org/patch/26366/
[2] https://patchwork.linuxtv.org/patch/26367/
[3] https://patchwork.linuxtv.org/patch/26368/
Jacek Anaszewski (13):
mediactl: Introduce v4l2_subdev structure
mediactl: Add support for v4l2-ctrl-redir config
mediatext: Add library
mediactl: Add media device graph helpers
mediactl: Add media_device creation helpers
mediactl: libv4l2subdev: add VYUY8_2X8 mbus code
mediactl: Add support for media device pipelines
mediactl: libv4l2subdev: add support for comparing mbus formats
mediactl: libv4l2subdev: add support for setting pipeline format
mediactl: libv4l2subdev: add get_pipeline_entity_by_cid function
mediactl: Add media device ioctl API
mediactl: libv4l2subdev: Enable opening/closing pipelines
Add a libv4l plugin for Exynos4 camera
Sakari Ailus (1):
mediactl: Separate entity and pad parsing
configure.ac | 1 +
lib/Makefile.am | 5 +
lib/libv4l-exynos4-camera/Makefile.am | 7 +
lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 586 +++++++++++++++++++++
utils/media-ctl/Makefile.am | 12 +-
utils/media-ctl/libmediactl.c | 271 +++++++++-
utils/media-ctl/libmediatext.pc.in | 10 +
utils/media-ctl/libv4l2media_ioctl.c | 369 +++++++++++++
utils/media-ctl/libv4l2media_ioctl.h | 40 ++
utils/media-ctl/libv4l2subdev.c | 301 ++++++++++-
utils/media-ctl/mediactl-priv.h | 11 +-
utils/media-ctl/mediactl.h | 151 ++++++
utils/media-ctl/mediatext-test.c | 64 +++
utils/media-ctl/mediatext.c | 311 +++++++++++
utils/media-ctl/mediatext.h | 52 ++
utils/media-ctl/v4l2subdev.h | 131 +++++
16 files changed, 2292 insertions(+), 30 deletions(-)
create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
create mode 100644 utils/media-ctl/libmediatext.pc.in
create mode 100644 utils/media-ctl/libv4l2media_ioctl.c
create mode 100644 utils/media-ctl/libv4l2media_ioctl.h
create mode 100644 utils/media-ctl/mediatext-test.c
create mode 100644 utils/media-ctl/mediatext.c
create mode 100644 utils/media-ctl/mediatext.h
--
1.7.9.5
^ permalink raw reply [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 01/14] mediactl: Introduce v4l2_subdev structure
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 02/14] mediactl: Add support for v4l2-ctrl-redir config Jacek Anaszewski
` (13 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
Add struct v4l2_subdev - a representation of the v4l2 sub-device,
related to the media entity. Add field 'sd', the pointer to
the newly introduced structure, to the struct media_entity
and move 'fd' property from struct media entity to struct v4l2_subdev.
Avoid accessing sub-device file descriptor from libmediactl and
make the v4l2_subdev_open capable of creating the v4l2_subdev
if the 'sd' pointer is uninitialized.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
utils/media-ctl/libmediactl.c | 4 --
utils/media-ctl/libv4l2subdev.c | 82 +++++++++++++++++++++++++++++++--------
utils/media-ctl/mediactl-priv.h | 5 ++-
utils/media-ctl/v4l2subdev.h | 38 ++++++++++++++++++
4 files changed, 107 insertions(+), 22 deletions(-)
diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index ec360bd..4bb955f 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -511,7 +511,6 @@ static int media_enum_entities(struct media_device *media)
entity = &media->entities[media->entities_count];
memset(entity, 0, sizeof(*entity));
- entity->fd = -1;
entity->info.id = id | MEDIA_ENT_ID_FLAG_NEXT;
entity->media = media;
@@ -704,8 +703,6 @@ void media_device_unref(struct media_device *media)
free(entity->pads);
free(entity->links);
- if (entity->fd != -1)
- close(entity->fd);
}
free(media->entities);
@@ -732,7 +729,6 @@ int media_device_add_entity(struct media_device *media,
entity = &media->entities[media->entities_count - 1];
memset(entity, 0, sizeof *entity);
- entity->fd = -1;
entity->media = media;
strncpy(entity->devname, devnode, sizeof entity->devname);
entity->devname[sizeof entity->devname - 1] = '\0';
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 8015330..68404d4 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -39,13 +39,61 @@
#include "tools.h"
#include "v4l2subdev.h"
+int v4l2_subdev_create(struct media_entity *entity)
+{
+ if (entity->sd)
+ return 0;
+
+ entity->sd = calloc(1, sizeof(*entity->sd));
+ if (entity->sd == NULL)
+ return -ENOMEM;
+
+ entity->sd->fd = -1;
+
+ return 0;
+}
+
+int v4l2_subdev_create_with_fd(struct media_entity *entity, int fd)
+{
+ int ret;
+
+ if (entity->sd)
+ return -EEXIST;
+
+ ret = v4l2_subdev_create(entity);
+ if (ret < 0)
+ return ret;
+
+ entity->sd->fd = fd;
+
+ return 0;
+}
+
+void v4l2_subdev_release(struct media_entity *entity, bool close_fd)
+{
+ if (entity->sd == NULL)
+ return;
+
+ if (close_fd)
+ v4l2_subdev_close(entity);
+
+ free(entity->sd->v4l2_control_redir);
+ free(entity->sd);
+}
+
int v4l2_subdev_open(struct media_entity *entity)
{
- if (entity->fd != -1)
+ int ret;
+
+ ret = v4l2_subdev_create(entity);
+ if (ret < 0)
+ return ret;
+
+ if (entity->sd->fd != -1)
return 0;
- entity->fd = open(entity->devname, O_RDWR);
- if (entity->fd == -1) {
+ entity->sd->fd = open(entity->devname, O_RDWR);
+ if (entity->sd->fd == -1) {
int ret = -errno;
media_dbg(entity->media,
"%s: Failed to open subdev device node %s\n", __func__,
@@ -58,8 +106,8 @@ int v4l2_subdev_open(struct media_entity *entity)
void v4l2_subdev_close(struct media_entity *entity)
{
- close(entity->fd);
- entity->fd = -1;
+ close(entity->sd->fd);
+ entity->sd->fd = -1;
}
int v4l2_subdev_get_format(struct media_entity *entity,
@@ -77,7 +125,7 @@ int v4l2_subdev_get_format(struct media_entity *entity,
fmt.pad = pad;
fmt.which = which;
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_FMT, &fmt);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_G_FMT, &fmt);
if (ret < 0)
return -errno;
@@ -101,7 +149,7 @@ int v4l2_subdev_set_format(struct media_entity *entity,
fmt.which = which;
fmt.format = *format;
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_FMT, &fmt);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_S_FMT, &fmt);
if (ret < 0)
return -errno;
@@ -128,7 +176,7 @@ int v4l2_subdev_get_selection(struct media_entity *entity,
u.sel.target = target;
u.sel.which = which;
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_SELECTION, &u.sel);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_G_SELECTION, &u.sel);
if (ret >= 0) {
*rect = u.sel.r;
return 0;
@@ -140,7 +188,7 @@ int v4l2_subdev_get_selection(struct media_entity *entity,
u.crop.pad = pad;
u.crop.which = which;
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_CROP, &u.crop);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_G_CROP, &u.crop);
if (ret < 0)
return -errno;
@@ -168,7 +216,7 @@ int v4l2_subdev_set_selection(struct media_entity *entity,
u.sel.which = which;
u.sel.r = *rect;
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_SELECTION, &u.sel);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_S_SELECTION, &u.sel);
if (ret >= 0) {
*rect = u.sel.r;
return 0;
@@ -181,7 +229,7 @@ int v4l2_subdev_set_selection(struct media_entity *entity,
u.crop.which = which;
u.crop.rect = *rect;
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_CROP, &u.crop);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_S_CROP, &u.crop);
if (ret < 0)
return -errno;
@@ -202,7 +250,7 @@ int v4l2_subdev_get_dv_timings_caps(struct media_entity *entity,
memset(caps, 0, sizeof(*caps));
caps->pad = pad;
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_DV_TIMINGS_CAP, caps);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_DV_TIMINGS_CAP, caps);
if (ret < 0)
return -errno;
@@ -220,7 +268,7 @@ int v4l2_subdev_query_dv_timings(struct media_entity *entity,
memset(timings, 0, sizeof(*timings));
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_QUERY_DV_TIMINGS, timings);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_QUERY_DV_TIMINGS, timings);
if (ret < 0)
return -errno;
@@ -238,7 +286,7 @@ int v4l2_subdev_get_dv_timings(struct media_entity *entity,
memset(timings, 0, sizeof(*timings));
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_DV_TIMINGS, timings);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_G_DV_TIMINGS, timings);
if (ret < 0)
return -errno;
@@ -254,7 +302,7 @@ int v4l2_subdev_set_dv_timings(struct media_entity *entity,
if (ret < 0)
return ret;
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_DV_TIMINGS, timings);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_S_DV_TIMINGS, timings);
if (ret < 0)
return -errno;
@@ -273,7 +321,7 @@ int v4l2_subdev_get_frame_interval(struct media_entity *entity,
memset(&ival, 0, sizeof(ival));
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_FRAME_INTERVAL, &ival);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_G_FRAME_INTERVAL, &ival);
if (ret < 0)
return -errno;
@@ -294,7 +342,7 @@ int v4l2_subdev_set_frame_interval(struct media_entity *entity,
memset(&ival, 0, sizeof(ival));
ival.interval = *interval;
- ret = ioctl(entity->fd, VIDIOC_SUBDEV_S_FRAME_INTERVAL, &ival);
+ ret = ioctl(entity->sd->fd, VIDIOC_SUBDEV_S_FRAME_INTERVAL, &ival);
if (ret < 0)
return -errno;
diff --git a/utils/media-ctl/mediactl-priv.h b/utils/media-ctl/mediactl-priv.h
index a0d3a55..f531c52 100644
--- a/utils/media-ctl/mediactl-priv.h
+++ b/utils/media-ctl/mediactl-priv.h
@@ -26,6 +26,8 @@
#include "mediactl.h"
+struct v4l2_subdev;
+
struct media_entity {
struct media_device *media;
struct media_entity_desc info;
@@ -34,8 +36,9 @@ struct media_entity {
unsigned int max_links;
unsigned int num_links;
+ struct v4l2_subdev *sd;
+
char devname[32];
- int fd;
};
struct media_device {
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index 1cb53ff..b386294 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -26,6 +26,44 @@
struct media_entity;
+struct v4l2_subdev {
+ int fd;
+};
+
+/**
+ * @brief Create a v4l2-subdev
+ * @param entity - sub-device media entity.
+ *
+ * Create the representation of the entity sub-device.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int v4l2_subdev_create(struct media_entity *entity);
+
+/**
+ * @brief Create a representation of the already opened v4l2-subdev
+ * @param entity - sub-device media entity.
+ * @param fd - sub-device file descriptor.
+ *
+ * Create the representation of the sub-device that had been opened
+ * before the parent media device was created, and associate it
+ * with the media entity.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int v4l2_subdev_create_with_fd(struct media_entity *entity, int fd);
+
+/**
+ * @brief Release a v4l2-subdev
+ * @param entity - sub-device media entity.
+ * @param close_fd - indicates whether subdev fd should be closed.
+ *
+ * Release the representation of the entity sub-device.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+void v4l2_subdev_release(struct media_entity *entity, bool close_fd);
+
/**
* @brief Open a sub-device.
* @param entity - sub-device media entity.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 02/14] mediactl: Add support for v4l2-ctrl-redir config
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 01/14] mediactl: Introduce v4l2_subdev structure Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 03/14] mediactl: Separate entity and pad parsing Jacek Anaszewski
` (12 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
Make struct v4l2_subdev capable of aggregating v4l2-ctrl-redir
media device configuration entries. Added are also functions for
validating the config and checking whether a v4l2 sub-device
expects to receive ioctls related to the v4l2-control with given id.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
utils/media-ctl/libv4l2subdev.c | 49 ++++++++++++++++++++++++++++++++++++++-
utils/media-ctl/v4l2subdev.h | 33 ++++++++++++++++++++++++++
2 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 68404d4..5b9d908 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -26,7 +26,6 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
-#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -50,7 +49,15 @@ int v4l2_subdev_create(struct media_entity *entity)
entity->sd->fd = -1;
+ entity->sd->v4l2_control_redir = malloc(sizeof(__u32));
+ if (entity->sd->v4l2_control_redir == NULL)
+ goto err_v4l2_control_redir_alloc;
+
return 0;
+
+err_v4l2_control_redir_alloc:
+ free(entity->sd);
+ return -ENOMEM;
}
int v4l2_subdev_create_with_fd(struct media_entity *entity, int fd)
@@ -803,3 +810,43 @@ enum v4l2_mbus_pixelcode v4l2_subdev_string_to_pixelcode(const char *string,
return mbus_formats[i].code;
}
+
+int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media,
+ struct media_entity *entity,
+ __u32 ctrl_id)
+{
+ struct v4l2_queryctrl queryctrl = {};
+ int ret;
+
+ ret = v4l2_subdev_open(entity);
+ if (ret < 0)
+ return ret;
+
+ queryctrl.id = ctrl_id;
+
+ ret = ioctl(entity->sd->fd, VIDIOC_QUERYCTRL, &queryctrl);
+ if (ret < 0)
+ return ret;
+
+ media_dbg(media, "Validated control \"%s\" (0x%8.8x) on entity %s\n",
+ queryctrl.name, queryctrl.id, entity->info.name);
+
+ return 0;
+}
+
+bool v4l2_subdev_has_v4l2_control_redir(struct media_device *media,
+ struct media_entity *entity,
+ int ctrl_id)
+{
+ struct v4l2_subdev *sd = entity->sd;
+ int i;
+
+ if (!sd)
+ return false;
+
+ for (i = 0; i < sd->v4l2_control_redir_num; ++i)
+ if (sd->v4l2_control_redir[i] == ctrl_id)
+ return true;
+
+ return false;
+}
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index b386294..07f9697 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -23,11 +23,16 @@
#define __SUBDEV_H__
#include <linux/v4l2-subdev.h>
+#include <stdbool.h>
struct media_entity;
+struct media_device;
struct v4l2_subdev {
int fd;
+
+ __u32 *v4l2_control_redir;
+ unsigned int v4l2_control_redir_num;
};
/**
@@ -293,4 +298,32 @@ const char *v4l2_subdev_pixelcode_to_string(enum v4l2_mbus_pixelcode code);
*/
enum v4l2_mbus_pixelcode v4l2_subdev_string_to_pixelcode(const char *string,
unsigned int length);
+
+/**
+ * @brief Validate v4l2 control for a sub-device
+ * @param media - media device.
+ * @param entity - subdev-device media entity.
+ * @param ctrl_id - id of the v4l2 control to validate.
+ *
+ * Verify if the entity supports v4l2-control with given ctrl_id.
+ *
+ * @return 1 if the control is supported, 0 otherwise.
+ */
+int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media,
+ struct media_entity *entity,
+ __u32 ctrl_id);
+
+/**
+ * @brief Check if there was a v4l2_control redirection defined for the entity
+ * @param media - media device.
+ * @param entity - subdev-device media entity.
+ * @param ctrl_id - v4l2 control identifier.
+ *
+ * Check if there was a v4l2-ctrl-redir entry defined for the entity.
+ *
+ * @return true if the entry exists, false otherwise
+ */
+bool v4l2_subdev_has_v4l2_control_redir(struct media_device *media,
+ struct media_entity *entity, int ctrl_id);
+
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 03/14] mediactl: Separate entity and pad parsing
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 01/14] mediactl: Introduce v4l2_subdev structure Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 02/14] mediactl: Add support for v4l2-ctrl-redir config Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 04/14] mediatext: Add library Jacek Anaszewski
` (11 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park
From: Sakari Ailus <sakari.ailus@linux.intel.com>
Sometimes it's useful to be able to parse the entity independent of the pad.
Separate entity parsing into media_parse_entity().
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
utils/media-ctl/libmediactl.c | 28 ++++++++++++++++++++++++----
utils/media-ctl/mediactl.h | 14 ++++++++++++++
2 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index 4bb955f..bbaf387 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -766,10 +766,10 @@ int media_device_add_entity(struct media_device *media,
return 0;
}
-struct media_pad *media_parse_pad(struct media_device *media,
- const char *p, char **endp)
+struct media_entity *media_parse_entity(struct media_device *media,
+ const char *p, char **endp)
{
- unsigned int entity_id, pad;
+ unsigned int entity_id;
struct media_entity *entity;
char *end;
@@ -806,7 +806,27 @@ struct media_pad *media_parse_pad(struct media_device *media,
return NULL;
}
}
- for (; isspace(*end); ++end);
+ for (p = end; isspace(*p); ++p);
+
+ *endp = (char *)p;
+
+ return entity;
+}
+
+struct media_pad *media_parse_pad(struct media_device *media,
+ const char *p, char **endp)
+{
+ unsigned int pad;
+ struct media_entity *entity;
+ char *end;
+
+ if (endp == NULL)
+ endp = &end;
+
+ entity = media_parse_entity(media, p, &end);
+ if (!entity)
+ return NULL;
+ *endp = end;
if (*end != ':') {
media_dbg(media, "Expected ':'\n", *end);
diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h
index 77ac182..3faee71 100644
--- a/utils/media-ctl/mediactl.h
+++ b/utils/media-ctl/mediactl.h
@@ -368,6 +368,20 @@ int media_setup_link(struct media_device *media,
int media_reset_links(struct media_device *media);
/**
+ * @brief Parse string to an entity on the media device.
+ * @param media - media device.
+ * @param p - input string
+ * @param endp - pointer to string where parsing ended
+ *
+ * Parse NULL terminated string describing an entity and return its
+ * struct media_entity instance.
+ *
+ * @return Pointer to struct media_entity on success, NULL on failure.
+ */
+struct media_entity *media_parse_entity(struct media_device *media,
+ const char *p, char **endp);
+
+/**
* @brief Parse string to a pad on the media device.
* @param media - media device.
* @param p - input string
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 04/14] mediatext: Add library
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (2 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 03/14] mediactl: Separate entity and pad parsing Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 05/14] mediactl: Add media device graph helpers Jacek Anaszewski
` (10 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski, Teemu Tuominen
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 14351 bytes --]
libmediatext is a helper library for converting configurations (Media
controller links, V4L2 controls and V4L2 sub-device media bus formats and
selections) from text-based form into IOCTLs.
libmediatext depends on libv4l2subdev and libmediactl.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Teemu Tuominen <teemu.tuominen@intel.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
---
utils/media-ctl/Makefile.am | 10 +-
utils/media-ctl/libmediatext.pc.in | 10 ++
utils/media-ctl/mediatext-test.c | 64 ++++++++
utils/media-ctl/mediatext.c | 311 ++++++++++++++++++++++++++++++++++++
utils/media-ctl/mediatext.h | 52 ++++++
5 files changed, 445 insertions(+), 2 deletions(-)
create mode 100644 utils/media-ctl/libmediatext.pc.in
create mode 100644 utils/media-ctl/mediatext-test.c
create mode 100644 utils/media-ctl/mediatext.c
create mode 100644 utils/media-ctl/mediatext.h
diff --git a/utils/media-ctl/Makefile.am b/utils/media-ctl/Makefile.am
index a3931fb..3e883e0 100644
--- a/utils/media-ctl/Makefile.am
+++ b/utils/media-ctl/Makefile.am
@@ -1,4 +1,4 @@
-noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la
+noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la
libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h
libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS)
@@ -9,9 +9,15 @@ libv4l2subdev_la_LIBADD = libmediactl.la
libv4l2subdev_la_CFLAGS = -static
libv4l2subdev_la_LDFLAGS = -static
+libmediatext_la_SOURCES = mediatext.c
+libmediatext_la_CFLAGS = -static $(LIBUDEV_CFLAGS)
+libmediatext_la_LDFLAGS = -static $(LIBUDEV_LIBS)
+
mediactl_includedir=$(includedir)/mediactl
noinst_HEADERS = mediactl.h v4l2subdev.h
-bin_PROGRAMS = media-ctl
+bin_PROGRAMS = media-ctl mediatext-test
media_ctl_SOURCES = media-ctl.c options.c options.h tools.h
media_ctl_LDADD = libmediactl.la libv4l2subdev.la
+mediatext_test_SOURCES = mediatext-test.c
+mediatext_test_LDADD = libmediatext.la libmediactl.la libv4l2subdev.la
diff --git a/utils/media-ctl/libmediatext.pc.in b/utils/media-ctl/libmediatext.pc.in
new file mode 100644
index 0000000..6aa6353
--- /dev/null
+++ b/utils/media-ctl/libmediatext.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libmediatext
+Description: Media controller and V4L2 text-based configuration library
+Version: @PACKAGE_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lmediatext
diff --git a/utils/media-ctl/mediatext-test.c b/utils/media-ctl/mediatext-test.c
new file mode 100644
index 0000000..e3ae89c
--- /dev/null
+++ b/utils/media-ctl/mediatext-test.c
@@ -0,0 +1,64 @@
+/*
+ * libmediatext test program
+ *
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Contact: Sakari Ailus <sakari.ailus@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "mediactl.h"
+#include "mediatext.h"
+
+int main(int argc, char *argv[])
+{
+ struct media_device *device;
+ int rval;
+
+ if (argc != 3) {
+ fprintf(stderr, "usage: %s <media device> <string>\n\n", argv[0]);
+ fprintf(stderr, "\tstring := [ v4l2-ctrl | v4l2-mbus | link-reset | link-conf]\n\n");
+ fprintf(stderr, "\tv4l2-ctrl := \"entity\" ctrl_type ctrl_id ctrl_value\n");
+ fprintf(stderr, "\tctrl_type := [ int | int64 | bitmask ]\n");
+ fprintf(stderr, "\tctrl_value := [ %%d | %%PRId64 | bitmask_value ]\n");
+ fprintf(stderr, "\tbitmask_value := b<binary_number>\n\n");
+ fprintf(stderr, "\tv4l2-mbus := \n");
+ fprintf(stderr, "\tlink-conf := \"entity\":pad -> \"entity\":pad[link-flags]\n");
+ fprintf(stderr, "\tv4l2-ctrl-redir := ctrl_id -> \"entity\"\n");
+ return EXIT_FAILURE;
+ }
+
+ device = media_device_new(argv[1]);
+ if (!device)
+ return EXIT_FAILURE;
+
+ rval = media_device_enumerate(device);
+ if (rval)
+ return EXIT_FAILURE;
+
+ rval = mediatext_parse(device, argv[2]);
+ if (rval) {
+ fprintf(stderr, "bad string %s (%s)\n", argv[2], strerror(-rval));
+ return EXIT_FAILURE;
+ }
+
+ media_device_unref(device);
+
+ return EXIT_SUCCESS;
+}
diff --git a/utils/media-ctl/mediatext.c b/utils/media-ctl/mediatext.c
new file mode 100644
index 0000000..c39e889
--- /dev/null
+++ b/utils/media-ctl/mediatext.c
@@ -0,0 +1,311 @@
+/*
+ * Media controller text-based configuration library
+ *
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Contact: Sakari Ailus <sakari.ailus@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/ioctl.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#include <linux/types.h>
+
+#include "mediactl.h"
+#include "mediactl-priv.h"
+#include "tools.h"
+#include "v4l2subdev.h"
+
+struct parser {
+ char *prefix;
+ int (*parse)(struct media_device *media, const struct parser *p,
+ char *string);
+ struct parser *next;
+ bool no_args;
+};
+
+static int parse(struct media_device *media, const struct parser *p, char *string)
+{
+ for (; p->prefix; p++) {
+ size_t len = strlen(p->prefix);
+
+ if (strncmp(p->prefix, string, len) || string[len] != ' ')
+ continue;
+
+ string += len;
+
+ for (; isspace(*string); string++);
+
+ if (p->no_args)
+ return p->parse(media, p->next, NULL);
+
+ if (strlen(string) == 0)
+ return -ENOEXEC;
+
+ return p->parse(media, p->next, string);
+ }
+
+ media_dbg(media, "Unknown parser prefix\n");
+
+ return -ENOENT;
+}
+
+struct ctrl_type {
+ uint32_t type;
+ char *str;
+} ctrltypes[] = {
+ { V4L2_CTRL_TYPE_INTEGER, "int" },
+ { V4L2_CTRL_TYPE_MENU, "menu" },
+ { V4L2_CTRL_TYPE_INTEGER_MENU, "intmenu" },
+ { V4L2_CTRL_TYPE_BITMASK, "bitmask" },
+ { V4L2_CTRL_TYPE_INTEGER64, "int64" },
+};
+
+static int parse_v4l2_ctrl_id(struct media_device *media, const struct parser *p,
+ char *string, char **endp, __u32 *ctrl_id)
+{
+ int rval;
+
+ for (; isspace(*string); string++);
+ rval = sscanf(string, "0x%" PRIx32, ctrl_id);
+ if (rval <= 0)
+ return -EINVAL;
+
+ for (; !isspace(*string) && *string; string++);
+ for (; isspace(*string); string++);
+
+ *endp = string;
+
+ return 0;
+}
+
+/* adapted from yavta.c */
+static int parse_v4l2_ctrl(struct media_device *media, const struct parser *p,
+ char *string)
+{
+ struct v4l2_ext_control ctrl = { 0 };
+ struct v4l2_ext_controls ctrls = { .count = 1,
+ .controls = &ctrl };
+ int64_t val;
+ int rval;
+ struct media_entity *entity;
+ struct ctrl_type *ctype;
+ unsigned int i;
+
+ entity = media_parse_entity(media, string, &string);
+ if (!entity)
+ return -ENOENT;
+
+ for (i = 0; i < ARRAY_SIZE(ctrltypes); i++)
+ if (!strncmp(string, ctrltypes[i].str,
+ strlen(ctrltypes[i].str)))
+ break;
+
+ if (i == ARRAY_SIZE(ctrltypes))
+ return -ENOENT;
+
+ ctype = &ctrltypes[i];
+
+ string += strlen(ctrltypes[i].str);
+
+ rval = parse_v4l2_ctrl_id(media, p, string, &string, &ctrl.id);
+ if (rval < 0)
+ return -EINVAL;
+
+ ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(ctrl.id);
+
+ switch (ctype->type) {
+ case V4L2_CTRL_TYPE_BITMASK:
+ if (*string++ != 'b')
+ return -EINVAL;
+ while (*string == '1' || *string == '0') {
+ val <<= 1;
+ if (*string == '1')
+ val++;
+ string++;
+ }
+ break;
+ default:
+ rval = sscanf(string, "%" PRId64, &val);
+ break;
+ }
+ if (rval <= 0)
+ return -EINVAL;
+
+ media_dbg(media, "Setting control 0x%8.8x (type %s), value %" PRId64 "\n",
+ ctrl.id, ctype->str, val);
+
+ if (ctype->type == V4L2_CTRL_TYPE_INTEGER64)
+ ctrl.value64 = val;
+ else
+ ctrl.value = val;
+
+ rval = v4l2_subdev_open(entity);
+ if (rval < 0)
+ return rval;
+
+ rval = ioctl(entity->sd->fd, VIDIOC_S_EXT_CTRLS, &ctrls);
+ if (ctype->type != V4L2_CTRL_TYPE_INTEGER64) {
+ if (rval != -1) {
+ ctrl.value64 = ctrl.value;
+ } else if (ctype->type != V4L2_CTRL_TYPE_STRING &&
+ (errno == EINVAL || errno == ENOTTY)) {
+ struct v4l2_control old = { .id = ctrl.id,
+ .value = val };
+
+ rval = ioctl(entity->sd->fd, VIDIOC_S_CTRL, &old);
+ if (rval != -1)
+ ctrl.value64 = old.value;
+ }
+ }
+ if (rval == -1) {
+ media_dbg(media,
+ "Failed setting control 0x%8.8x: %s (%d) to value %"
+ PRId64 "\n", ctrl.id, strerror(errno), errno, val);
+ return -errno;
+ }
+
+ if (val != ctrl.value64)
+ media_dbg(media, "Asking for %" PRId64 ", got %" PRId64 "\n",
+ val, ctrl.value64);
+
+ return 0;
+}
+
+/*
+
+parse_name(string, end)
+
+*/
+
+int parse_v4l2_ctrl_redir(struct media_device *media, const struct parser *p,
+ char *string)
+{
+ struct media_entity *entity;
+ struct v4l2_subdev *sd;
+ __u32 ctrl_id;
+ int rval;
+
+ rval = parse_v4l2_ctrl_id(media, p, string, &string, &ctrl_id);
+ if (rval < 0)
+ return -EINVAL;
+
+ for (; isspace(*string); ++string);
+
+ if (string[0] != '-' || string[1] != '>') {
+ media_dbg(media, "Expected '->'\n");
+ return -EINVAL;
+ }
+
+ string += 2;
+
+ entity = media_parse_entity(media, string, &string);
+ if (!entity)
+ return -ENOENT;
+
+ rval = v4l2_subdev_validate_v4l2_ctrl(media, entity, ctrl_id);
+ if (rval < 0) {
+ media_dbg(media, "Failed to validate a v4l2 control on entity %s\n",
+ entity->info.name);
+ return rval;
+ }
+
+ sd = entity->sd;
+
+ sd->v4l2_control_redir = realloc(sd->v4l2_control_redir,
+ sizeof(*sd->v4l2_control_redir) *
+ (sd->v4l2_control_redir_num + 1));
+ if (!sd->v4l2_control_redir)
+ return -ENOMEM;
+
+ sd->v4l2_control_redir[sd->v4l2_control_redir_num] = ctrl_id;
+ ++sd->v4l2_control_redir_num;
+
+ return 0;
+}
+
+static int parse_v4l2_mbus(struct media_device *media, const struct parser *p,
+ char *string)
+{
+ media_dbg(media, "Media bus format setup: %s\n", string);
+ return v4l2_subdev_parse_setup_formats(media, string);
+}
+
+static int parse_link_reset(struct media_device *media, const struct parser *p,
+ char *string)
+{
+ media_dbg(media, "Resetting links\n");
+ return media_reset_links(media);
+}
+
+static int parse_link_conf(struct media_device *media, const struct parser *p,
+ char *string)
+{
+ media_dbg(media, "Configuring links: %s\n", string);
+ return media_parse_setup_links(media, string);
+}
+
+static const struct parser parsers[] = {
+ { "v4l2-ctrl", parse_v4l2_ctrl },
+ { "v4l2-ctrl-redir", parse_v4l2_ctrl_redir },
+ { "v4l2-mbus", parse_v4l2_mbus },
+ { "link-reset", parse_link_reset, NULL, true },
+ { "link-conf", parse_link_conf },
+ { 0 }
+};
+
+int mediatext_parse(struct media_device *media, char *string)
+{
+ return parse(media, parsers, string);
+}
+
+int mediatext_parse_setup_config(struct media_device *device, const char *conf_path)
+{
+ char *line;
+ size_t n = 0;
+ FILE *f;
+ int ret;
+
+ if (conf_path == NULL)
+ return -EINVAL;
+
+ f = fopen(conf_path, "r");
+ if (!f)
+ return -EINVAL;
+
+ while (getline(&line, &n, f) != -1) {
+ ret = mediatext_parse(device, line);
+ if (ret < 0)
+ goto err_parse;
+ free(line);
+ line = NULL;
+ n = 0;
+ }
+
+err_parse:
+ fclose(f);
+ return ret;
+}
diff --git a/utils/media-ctl/mediatext.h b/utils/media-ctl/mediatext.h
new file mode 100644
index 0000000..7dfbaf6
--- /dev/null
+++ b/utils/media-ctl/mediatext.h
@@ -0,0 +1,52 @@
+/*
+ * Media controller text-based configuration library
+ *
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Contact: Sakari Ailus <sakari.ailus@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __MEDIATEXT_H__
+#define __MEDIATEXT_H__
+
+struct media_device;
+
+/**
+ * @brief Parse and apply media device command
+ * @param device - media device
+ * @param string - string to parse
+ *
+ * Parse media device command and apply it to the media device
+ * passed in the device argument.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int mediatext_parse(struct media_device *device, char *string);
+
+/**
+ * @brief Parse and apply media device configuration
+ * @param media - media device
+ * @param conf_path - path to the configuration file
+ *
+ * Parse the media device commands listed in the file under
+ * conf_path and apply them to the media device passed in the
+ * device argument.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int mediatext_parse_setup_config(struct media_device *device, const char *conf_path);
+
+#endif /* __MEDIATEXT_H__ */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 05/14] mediactl: Add media device graph helpers
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (3 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 04/14] mediatext: Add library Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 06/14] mediactl: Add media_device creation helpers Jacek Anaszewski
` (9 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
Add new graph helpers useful for video pipeline discovering.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
utils/media-ctl/libmediactl.c | 48 +++++++++++++++++++++++++++++++++++++++++
utils/media-ctl/mediactl.h | 36 +++++++++++++++++++++++++++++++
2 files changed, 84 insertions(+)
diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index bbaf387..a294ada 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -35,6 +35,7 @@
#include <unistd.h>
#include <linux/media.h>
+#include <linux/kdev_t.h>
#include <linux/videodev2.h>
#include "mediactl.h"
@@ -87,6 +88,29 @@ struct media_entity *media_get_entity_by_name(struct media_device *media,
return NULL;
}
+struct media_entity *media_get_entity_by_devname(struct media_device *media,
+ const char *devname,
+ size_t length)
+{
+ unsigned int i;
+
+ /* A match is impossible if the entity devname is longer than the
+ * maximum size we can get from the kernel.
+ */
+ if (length >= FIELD_SIZEOF(struct media_entity, devname))
+ return NULL;
+
+ for (i = 0; i < media->entities_count; ++i) {
+ struct media_entity *entity = &media->entities[i];
+
+ if (strncmp(entity->devname, devname, length) == 0 &&
+ entity->devname[length] == '\0')
+ return entity;
+ }
+
+ return NULL;
+}
+
struct media_entity *media_get_entity_by_id(struct media_device *media,
__u32 id)
{
@@ -145,6 +169,11 @@ const char *media_entity_get_devname(struct media_entity *entity)
return entity->devname[0] ? entity->devname : NULL;
}
+const char *media_entity_get_name(struct media_entity *entity)
+{
+ return entity->info.name;
+}
+
struct media_entity *media_get_default_entity(struct media_device *media,
unsigned int type)
{
@@ -177,6 +206,25 @@ const struct media_entity_desc *media_entity_get_info(struct media_entity *entit
return &entity->info;
}
+int media_get_backlinks_by_entity(struct media_entity *entity,
+ struct media_link **backlinks,
+ int *num_backlinks)
+{
+ int num_bklinks = 0, i;
+
+ if (entity == NULL || backlinks == NULL || num_backlinks == NULL)
+ return -EINVAL;
+
+ for (i = 0; i < entity->num_links; ++i)
+ if ((entity->links[i].flags & MEDIA_LNK_FL_ENABLED) &&
+ (entity->links[i].sink->entity == entity))
+ backlinks[num_bklinks++] = &entity->links[i];
+
+ *num_backlinks = num_bklinks;
+
+ return 0;
+}
+
/* -----------------------------------------------------------------------------
* Open/close
*/
diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h
index 3faee71..9db40a8 100644
--- a/utils/media-ctl/mediactl.h
+++ b/utils/media-ctl/mediactl.h
@@ -231,6 +231,15 @@ const struct media_link *media_entity_get_link(struct media_entity *entity,
const char *media_entity_get_devname(struct media_entity *entity);
/**
+ * @brief Get the name for an entity
+ * @param entity - media entity.
+ *
+ * This function returns the name of the entity.
+ *
+ * @return A pointer to the string with entity name
+ */
+const char *media_entity_get_name(struct media_entity *entity);
+
* @brief Get the type of an entity.
* @param entity - the entity.
*
@@ -255,6 +264,19 @@ struct media_entity *media_get_entity_by_name(struct media_device *media,
const char *name, size_t length);
/**
+ * @brief Find an entity by the corresponding device node name.
+ * @param media - media device.
+ * @param devname - device node name.
+ * @param length - size of @a devname.
+ *
+ * Search for an entity with a device node name equal to @a devname.
+ *
+ * @return A pointer to the entity if found, or NULL otherwise.
+ */
+struct media_entity *media_get_entity_by_devname(struct media_device *media,
+ const char *devname, size_t length);
+
+/**
* @brief Find an entity by its ID.
* @param media - media device.
* @param id - entity ID.
@@ -434,4 +456,18 @@ int media_parse_setup_link(struct media_device *media,
*/
int media_parse_setup_links(struct media_device *media, const char *p);
+/**
+ * @brief Get entity's enabled backlinks
+ * @param entity - media entity.
+ * @param backlinks - array of pointers to matching backlinks.
+ * @param num_backlinks - number of matching backlinks.
+ *
+ * Get links that are connected to the entity sink pads.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int media_get_backlinks_by_entity(struct media_entity *entity,
+ struct media_link **backlinks,
+ int *num_backlinks);
+
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 06/14] mediactl: Add media_device creation helpers
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (4 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 05/14] mediactl: Add media device graph helpers Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 07/14] mediactl: libv4l2subdev: add VYUY8_2X8 mbus code Jacek Anaszewski
` (8 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
Add helper functions that allow for easy instantiation of media_device
object basing on whether the media device contains video device with
given node name.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
utils/media-ctl/libmediactl.c | 75 +++++++++++++++++++++++++++++++++++++++++
utils/media-ctl/mediactl.h | 30 +++++++++++++++++
2 files changed, 105 insertions(+)
diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index a294ada..6d3e691 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -719,6 +719,44 @@ struct media_device *media_device_new(const char *devnode)
return media;
}
+struct media_device *media_device_new_by_entity_devname(char *entity_devname)
+{
+ struct media_device *media;
+ char media_devname[32];
+ struct media_entity *entity;
+ int i, ret;
+
+ /* query all available media devices */
+ for (i = 0;; ++i) {
+ sprintf(media_devname, "/dev/media%d", i);
+
+ media = media_device_new(media_devname);
+ if (media == NULL)
+ return NULL;
+
+ ret = media_device_enumerate(media);
+ if (ret < 0) {
+ media_dbg(media, "Failed to enumerate %s (%d)\n",
+ media_devname, ret);
+ goto err_dev_enum;
+ }
+
+ /* Check if the media device contains entity with entity_devname */
+ entity = media_get_entity_by_devname(media, entity_devname,
+ strlen(entity_devname));
+ if (entity)
+ return media;
+
+ if (media)
+ media_device_unref(media);
+ }
+
+err_dev_enum:
+ if (media)
+ media_device_unref(media);
+ return NULL;
+}
+
struct media_device *media_device_new_emulated(struct media_device_info *info)
{
struct media_device *media;
@@ -758,6 +796,43 @@ void media_device_unref(struct media_device *media)
free(media);
}
+int media_get_devname_by_fd(int fd, char *node_name)
+{
+ struct udev *udev;
+ struct media_entity tmp_entity;
+ struct stat stat;
+ int ret;
+
+ if (node_name == NULL)
+ return -EINVAL;
+
+ ret = fstat(fd, &stat);
+ if (ret < 0)
+ return -EINVAL;
+
+ tmp_entity.info.v4l.major = MAJOR(stat.st_rdev);
+ tmp_entity.info.v4l.minor = MINOR(stat.st_rdev);
+
+ ret = media_udev_open(&udev);
+ if (ret < 0)
+ printf("Can't get udev context\n");
+
+ /* Try to get the device name via udev */
+ ret = media_get_devname_udev(udev, &tmp_entity);
+ if (!ret)
+ goto out;
+
+ ret = media_get_devname_sysfs(&tmp_entity);
+ if (ret < 0)
+ goto err_get_devname;
+
+out:
+ strcpy(node_name, tmp_entity.devname);
+err_get_devname:
+ media_udev_close(udev);
+ return ret;
+}
+
int media_device_add_entity(struct media_device *media,
const struct media_entity_desc *desc,
const char *devnode)
diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h
index 9db40a8..1d62191 100644
--- a/utils/media-ctl/mediactl.h
+++ b/utils/media-ctl/mediactl.h
@@ -76,6 +76,23 @@ struct media_device *media_device_new(const char *devnode);
struct media_device *media_device_new_emulated(struct media_device_info *info);
/**
+ * @brief Create a new media device if it comprises entity with given devname
+ * @param entity_devname - device node name of the entity to be matched.
+ *
+ * Query all media devices available in the system to find the one comprising
+ * the entity with given devname. If the media device is matched then its
+ * instance is created and initialized with enumerated entities and links.
+ * The returned device can be accessed.
+ *
+ * Media devices are reference-counted, see media_device_ref() and
+ * media_device_unref() for more information.
+ *
+ * @return A pointer to the new media device or NULL if video_devname cannot
+ * be matched or memory cannot be allocated.
+ */
+struct media_device *media_device_new_by_entity_devname(char *entity_devname);
+
+/**
* @brief Take a reference to the device.
* @param media - device instance.
*
@@ -240,6 +257,19 @@ const char *media_entity_get_devname(struct media_entity *entity);
*/
const char *media_entity_get_name(struct media_entity *entity);
+/**
+ * @brief Get the device node name by its file descriptor
+ * @param fd - file descriptor of a device.
+ * @param node_name - output device node name string.
+ *
+ * This function returns the full path and name to the device node corresponding
+ * to the given file descriptor.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int media_get_devname_by_fd(int fd, char *node_name);
+
+/**
* @brief Get the type of an entity.
* @param entity - the entity.
*
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 07/14] mediactl: libv4l2subdev: add VYUY8_2X8 mbus code
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (5 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 06/14] mediactl: Add media_device creation helpers Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 08/14] mediactl: Add support for media device pipelines Jacek Anaszewski
` (7 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
The VYUY8_2X8 media bus format is the only one supported
by the S5C73M3 camera sensor, that is a part of the media
device on the Exynos4412-trats2 board.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
utils/media-ctl/libv4l2subdev.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 5b9d908..dfd3bd5 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -760,6 +760,7 @@ static struct {
{ "YUYV", V4L2_MBUS_FMT_YUYV8_1X16 },
{ "YUYV1_5X8", V4L2_MBUS_FMT_YUYV8_1_5X8 },
{ "YUYV2X8", V4L2_MBUS_FMT_YUYV8_2X8 },
+ { "VYUY8_2X8", V4L2_MBUS_FMT_VYUY8_2X8 },
{ "UYVY", V4L2_MBUS_FMT_UYVY8_1X16 },
{ "UYVY1_5X8", V4L2_MBUS_FMT_UYVY8_1_5X8 },
{ "UYVY2X8", V4L2_MBUS_FMT_UYVY8_2X8 },
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 08/14] mediactl: Add support for media device pipelines
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (6 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 07/14] mediactl: libv4l2subdev: add VYUY8_2X8 mbus code Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 09/14] mediactl: libv4l2subdev: add support for comparing mbus formats Jacek Anaszewski
` (6 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
Add infrastructure for linking media entities and discovering
media device pipelines.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
utils/media-ctl/libmediactl.c | 116 +++++++++++++++++++++++++++++++++++++++
utils/media-ctl/mediactl-priv.h | 6 ++
utils/media-ctl/mediactl.h | 71 ++++++++++++++++++++++++
3 files changed, 193 insertions(+)
diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
index 6d3e691..4f2122f 100644
--- a/utils/media-ctl/libmediactl.c
+++ b/utils/media-ctl/libmediactl.c
@@ -1094,3 +1094,119 @@ int media_parse_setup_links(struct media_device *media, const char *p)
return *end ? -EINVAL : 0;
}
+
+/* -----------------------------------------------------------------------------
+ * Pipeline operations
+ */
+
+int media_discover_pipeline_by_entity(struct media_device *media,
+ struct media_entity *entity)
+{
+ struct media_entity *pipe_head = NULL;
+ struct media_pad *src_pad;
+ struct media_link *link = NULL, *backlinks[10];
+ int i, num_backlinks, ret;
+
+ if (entity == NULL)
+ return -EINVAL;
+
+ for (;;) {
+ /* Make recently discovered entity the pipeline head */
+ if (pipe_head == NULL) {
+ pipe_head = entity;
+ } else {
+ entity->next = pipe_head;
+ pipe_head = entity;
+ }
+
+ /* Cache a source pad used for linking the entity */
+ if (link)
+ entity->pipe_src_pad = link->source;
+
+ ret = media_get_backlinks_by_entity(entity,
+ backlinks,
+ &num_backlinks);
+ if (ret < 0)
+ return ret;
+
+ /* check if pipeline source entity has been reached */
+ if (num_backlinks > 2) {
+ media_dbg(media, "Unexpected number of busy sink pads (%d)\n", num_backlinks);
+ return -EINVAL;
+ } else if (num_backlinks == 2) {
+ /*
+ * Allow two active pads only in case of
+ * S5C73M3-OIF entity.
+ */
+ if (strcmp(entity->info.name, "S5C73M3-OIF")) {
+ media_dbg(media, "Ambiguous media device topology: two busy sink pads");
+ return -EINVAL;
+ }
+ /*
+ * Two active links are allowed betwen S5C73M3-OIF and
+ * S5C73M3 entities. In such a case a route through pad
+ * with id == 0 has to be selected.
+ */
+ for (i = 0; i < num_backlinks; i++)
+ if (backlinks[i]->sink->index == 0)
+ link = backlinks[i];
+ } else if (num_backlinks == 1)
+ link = backlinks[0];
+ else
+ break;
+
+ /* Cache a sink pad used for linking the entity */
+ entity->pipe_sink_pad = link->sink;
+
+ media_dbg(media, "Discovered sink pad %d for the %s entity\n",
+ entity->pipe_sink_pad->index, media_entity_get_name(entity));
+
+ src_pad = media_entity_remote_source(link->sink);
+ if (!src_pad)
+ return -EINVAL;
+
+ entity = src_pad->entity;
+ }
+
+ media->pipeline = pipe_head;
+
+ return 0;
+}
+
+int media_has_pipeline_entity(struct media_entity *pipeline, char *entity_name)
+{
+ if (pipeline == NULL || entity_name == NULL)
+ return -EINVAL;
+
+ while (pipeline) {
+ if (!strcmp(pipeline->info.name, entity_name))
+ return 1;
+ pipeline = pipeline->next;
+ }
+
+ return 0;
+}
+
+/* -----------------------------------------------------------------------------
+ * Media entity access
+ */
+
+struct media_entity *media_get_pipeline(struct media_device *media)
+{
+ return media->pipeline;
+}
+
+int media_entity_get_src_pad_index(struct media_entity *entity)
+{
+ return entity->pipe_src_pad->index;
+}
+
+int media_entity_get_sink_pad_index(struct media_entity *entity)
+{
+ return entity->pipe_sink_pad->index;
+}
+
+struct media_entity *media_entity_get_next(struct media_entity *entity)
+{
+ return entity->next;
+}
diff --git a/utils/media-ctl/mediactl-priv.h b/utils/media-ctl/mediactl-priv.h
index f531c52..3378880 100644
--- a/utils/media-ctl/mediactl-priv.h
+++ b/utils/media-ctl/mediactl-priv.h
@@ -36,9 +36,14 @@ struct media_entity {
unsigned int max_links;
unsigned int num_links;
+ struct media_pad *pipe_src_pad;
+ struct media_pad *pipe_sink_pad;
+
struct v4l2_subdev *sd;
char devname[32];
+
+ struct media_entity *next;
};
struct media_device {
@@ -49,6 +54,7 @@ struct media_device {
struct media_device_info info;
struct media_entity *entities;
unsigned int entities_count;
+ struct media_entity *pipeline;
void (*debug_handler)(void *, ...);
void *debug_priv;
diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h
index 1d62191..4570160 100644
--- a/utils/media-ctl/mediactl.h
+++ b/utils/media-ctl/mediactl.h
@@ -500,4 +500,75 @@ int media_get_backlinks_by_entity(struct media_entity *entity,
struct media_link **backlinks,
int *num_backlinks);
+/**
+ * @brief Check presence of the entity in the pipeline
+ * @param pipeline - video pipeline within a media device.
+ * @param entity_name - name of the entity to search for.
+ *
+ * Check if the entity with entity_name belongs to
+ * the pipeline.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int media_has_pipeline_entity(struct media_entity *pipeline, char *entity_name);
+
+/**
+ * @brief Discover the video pipeline
+ * @param media - media device.
+ * @param entity - media entity.
+ *
+ * Discover the pipeline of sub-devices, by walking
+ * upstream starting from the passed sink entity until
+ * the camera sensor entity is encountered.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int media_discover_pipeline_by_entity(struct media_device *media,
+ struct media_entity *entity);
+
+/**
+ * @brief Get source pad of the pipeline entity
+ * @param entity - media entity.
+ *
+ * This function returns the source pad of the entity.
+ *
+ * @return entity source pad, or NULL if the entity is not linked.
+ */
+int media_entity_get_src_pad_index(struct media_entity *entity);
+
+/**
+ * @brief Get sink pad of the pipeline entity
+ * @param entity - media entity.
+ *
+ * This function returns the sink pad of the entity.
+ *
+ * @return entity sink pad, or NULL if the entity is not linked.
+ */
+int media_entity_get_sink_pad_index(struct media_entity *entity);
+
+/**
+ * @brief Get next entity in the pipeline
+ * @param entity - media entity
+ *
+ * This function gets the entity connected to a source pad of this entity.
+ *
+ * @return next enetity in the pipeline,
+ * or NULL if the entity is not linked
+ */
+struct media_entity *media_entity_get_next(struct media_entity *entity);
+
+/**
+ * @brief Get the video pipeline
+ * @param media - media device
+ *
+ * This function gets the pipeline of media entities. The pipeline
+ * source entity is a camera sensor and the sink one is the entity
+ * representing opened video device node. The pipeline has to be
+ * discovered with use of the function media_discover_pipeline_by_entity.
+ *
+ * @return first media_entity in the pipeline,
+ * or NULL if the pipeline hasn't been discovered
+ */
+struct media_entity *media_get_pipeline(struct media_device *media);
+
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 09/14] mediactl: libv4l2subdev: add support for comparing mbus formats
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (7 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 08/14] mediactl: Add support for media device pipelines Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 10/14] mediactl: libv4l2subdev: add support for setting pipeline format Jacek Anaszewski
` (5 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
This patch adds a function for checking whether two mbus formats
are compatible.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
utils/media-ctl/libv4l2subdev.c | 34 ++++++++++++++++++++++++++++++++++
utils/media-ctl/v4l2subdev.h | 12 ++++++++++++
2 files changed, 46 insertions(+)
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index dfd3bd5..b9a924c 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -835,6 +835,40 @@ int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media,
return 0;
}
+int v4l2_subdev_format_compare(struct v4l2_mbus_framefmt *fmt1,
+ struct v4l2_mbus_framefmt *fmt2)
+{
+ if (fmt1 == NULL || fmt2 == NULL)
+ return 0;
+
+ if (fmt1->width != fmt2->width) {
+ printf("width mismatch\n");
+ return 0;
+ }
+
+ if (fmt1->height != fmt2->height) {
+ printf("height mismatch\n");
+ return 0;
+ }
+
+ if (fmt1->code != fmt2->code) {
+ printf("mbus code mismatch\n");
+ return 0;
+ }
+
+ if (fmt1->field != fmt2->field) {
+ printf("field mismatch\n");
+ return 0;
+ }
+
+ if (fmt1->colorspace != fmt2->colorspace) {
+ printf("colorspace mismatch\n");
+ return 0;
+ }
+
+ return 1;
+}
+
bool v4l2_subdev_has_v4l2_control_redir(struct media_device *media,
struct media_entity *entity,
int ctrl_id)
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index 07f9697..2f74975 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -314,6 +314,18 @@ int v4l2_subdev_validate_v4l2_ctrl(struct media_device *media,
__u32 ctrl_id);
/**
+ * @brief Compare mbus formats
+ * @param fmt1 - 1st mbus format to compare.
+ * @param fmt2 - 2nd mbus format to compare.
+ *
+ * Check whether two mbus formats are compatible.
+ *
+ * @return 1 if formats are compatible, 0 otherwise.
+ */
+int v4l2_subdev_format_compare(struct v4l2_mbus_framefmt *fmt1,
+ struct v4l2_mbus_framefmt *fmt2);
+
+/**
* @brief Check if there was a v4l2_control redirection defined for the entity
* @param media - media device.
* @param entity - subdev-device media entity.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 10/14] mediactl: libv4l2subdev: add support for setting pipeline format
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (8 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 09/14] mediactl: libv4l2subdev: add support for comparing mbus formats Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 11/14] mediactl: libv4l2subdev: add get_pipeline_entity_by_cid function Jacek Anaszewski
` (4 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
This patch adds a function for setting the media device pipeline format.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
utils/media-ctl/libv4l2subdev.c | 61 +++++++++++++++++++++++++++++++++++++++
utils/media-ctl/v4l2subdev.h | 15 ++++++++++
2 files changed, 76 insertions(+)
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index b9a924c..cc3df1e 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -164,6 +164,67 @@ int v4l2_subdev_set_format(struct media_entity *entity,
return 0;
}
+int v4l2_subdev_apply_pipeline_fmt(struct media_device *media,
+ struct v4l2_format *fmt)
+{
+ struct v4l2_mbus_framefmt mbus_fmt = { 0 };
+ struct media_entity *entity = media->pipeline;
+ struct media_pad *pad;
+ int ret;
+
+ while (entity) {
+ /*
+ * Source entity is linked only through a source pad
+ * and this pad should be used for setting the format.
+ * For other entities set the format on a sink pad.
+ */
+ pad = entity->pipe_sink_pad ? entity->pipe_sink_pad :
+ entity->pipe_src_pad;
+ if (pad == NULL)
+ return -EINVAL;
+
+ ret = v4l2_subdev_get_format(entity, &mbus_fmt, pad->index,
+ V4L2_SUBDEV_FORMAT_TRY);
+
+ if (ret < 0)
+ return ret;
+
+ media_dbg(media, "VIDIOC_SUBDEV_G_FMT %s:%d: mbus_code: %s, width: %d, height: %d\n",
+ media_entity_get_name(entity), pad->index,
+ v4l2_subdev_pixelcode_to_string(mbus_fmt.code),
+ mbus_fmt.width, mbus_fmt.height);
+
+ ret = v4l2_subdev_set_format(entity, &mbus_fmt, pad->index,
+ V4L2_SUBDEV_FORMAT_ACTIVE);
+ if (ret < 0)
+ return ret;
+
+ media_dbg(media, "VIDIOC_SUBDEV_S_FMT %s:%d: mbus_code: %s, width: %d, height: %d\n",
+ media_entity_get_name(entity), pad->index,
+ v4l2_subdev_pixelcode_to_string(mbus_fmt.code),
+ mbus_fmt.width, mbus_fmt.height);
+
+ entity = entity->next;
+
+ /* Last entity in the pipeline is not a sub-device */
+ if (entity->next == NULL)
+ break;
+ }
+
+ /*
+ * Sink entity represents a video device node and is not
+ * a sub-device. Nonetheless because it has associated
+ * file descriptor and can expose v4l2-controls the
+ * v4l2-subdev structure is used for caching the
+ * related data.
+ */
+ ret = ioctl(entity->sd->fd, VIDIOC_S_FMT, fmt);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
int v4l2_subdev_get_selection(struct media_entity *entity,
struct v4l2_rect *rect, unsigned int pad, unsigned int target,
enum v4l2_subdev_format_whence which)
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index 2f74975..2b48fb5 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -131,6 +131,21 @@ int v4l2_subdev_set_format(struct media_entity *entity,
enum v4l2_subdev_format_whence which);
/**
+ * @brief Set media device pipeline format
+ * @param media - media device.
+ * @param fmt - negotiated format.
+ *
+ * Set the active format on all the media device pipeline entities.
+ * The format has to be at first negotiated with VIDIOC_SUBDEV_S_FMT
+ * by struct v4l2_subdev_format's 'whence' property set to
+ * V4L2_SUBDEV_FORMAT_TRY.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int v4l2_subdev_apply_pipeline_fmt(struct media_device *media,
+ struct v4l2_format *fmt);
+
+/**
* @brief Retrieve a selection rectangle on a pad.
* @param entity - subdev-device media entity.
* @param r - rectangle to be filled.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 11/14] mediactl: libv4l2subdev: add get_pipeline_entity_by_cid function
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (9 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 10/14] mediactl: libv4l2subdev: add support for setting pipeline format Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 12/14] mediactl: Add media device ioctl API Jacek Anaszewski
` (3 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
Add a function for obtaining the v4l2 sub-device for which
the v4l2 control related ioctl is predestined.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
utils/media-ctl/libv4l2subdev.c | 14 ++++++++++++++
utils/media-ctl/v4l2subdev.h | 15 +++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index cc3df1e..379fe64 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -946,3 +946,17 @@ bool v4l2_subdev_has_v4l2_control_redir(struct media_device *media,
return false;
}
+
+struct media_entity *v4l2_subdev_get_pipeline_entity_by_cid(struct media_device *media,
+ int cid)
+{
+ struct media_entity *entity = media->pipeline;
+
+ while (entity) {
+ if (v4l2_subdev_has_v4l2_control_redir(media, entity, cid))
+ return entity;
+ entity = entity->next;
+ }
+
+ return NULL;
+}
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index 2b48fb5..0f1deca 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -353,4 +353,19 @@ int v4l2_subdev_format_compare(struct v4l2_mbus_framefmt *fmt1,
bool v4l2_subdev_has_v4l2_control_redir(struct media_device *media,
struct media_entity *entity, int ctrl_id);
+/**
+ * @brief Get the first pipeline entity supporting the control
+ * @param media - media device.
+ * @param cid - v4l2 control identifier.
+ *
+ * Get the first entity in the media device pipeline,
+ * for which v4l2_control with cid is to be redirected
+ *
+ * @return associated entity if defined, or NULL if the
+ * control redirection wasn't defined for any entity
+ * in the pipeline
+ */
+struct media_entity *v4l2_subdev_get_pipeline_entity_by_cid(
+ struct media_device *media, int cid);
+
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 12/14] mediactl: Add media device ioctl API
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (10 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 11/14] mediactl: libv4l2subdev: add get_pipeline_entity_by_cid function Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 13/14] mediactl: libv4l2subdev: Enable opening/closing pipelines Jacek Anaszewski
` (2 subsequent siblings)
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
Ioctls executed on complex media devices need special handling.
For instance some ioctls need to be targeted for specific sub-devices,
depending on the media device configuration. The APIs being introduced
address such requirements.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
utils/media-ctl/Makefile.am | 2 +-
utils/media-ctl/libv4l2media_ioctl.c | 369 ++++++++++++++++++++++++++++++++++
utils/media-ctl/libv4l2media_ioctl.h | 40 ++++
3 files changed, 410 insertions(+), 1 deletion(-)
create mode 100644 utils/media-ctl/libv4l2media_ioctl.c
create mode 100644 utils/media-ctl/libv4l2media_ioctl.h
diff --git a/utils/media-ctl/Makefile.am b/utils/media-ctl/Makefile.am
index 3e883e0..7f18624 100644
--- a/utils/media-ctl/Makefile.am
+++ b/utils/media-ctl/Makefile.am
@@ -1,6 +1,6 @@
noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la
-libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h
+libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h libv4l2media_ioctl.c libv4l2media_ioctl.h
libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS)
libmediactl_la_LDFLAGS = -static $(LIBUDEV_LIBS)
diff --git a/utils/media-ctl/libv4l2media_ioctl.c b/utils/media-ctl/libv4l2media_ioctl.c
new file mode 100644
index 0000000..c324f01
--- /dev/null
+++ b/utils/media-ctl/libv4l2media_ioctl.c
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski <j.anaszewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <linux/videodev2.h>
+#include <sys/syscall.h>
+
+#include "libv4l2media_ioctl.h"
+#include "mediactl-priv.h"
+#include "mediactl.h"
+#include "v4l2subdev.h"
+
+#define VIDIOC_CTRL(type) \
+ ((type) == VIDIOC_S_CTRL ? "VIDIOC_S_CTRL" : \
+ "VIDIOC_G_CTRL")
+
+#define VIDIOC_EXT_CTRL(type) \
+ ((type) == VIDIOC_S_EXT_CTRLS ? \
+ "VIDIOC_S_EXT_CTRLS" : \
+ ((type) == VIDIOC_G_EXT_CTRLS ? \
+ "VIDIOC_G_EXT_CTRLS" : \
+ "VIDIOC_TRY_EXT_CTRLS"))
+
+#define SYS_IOCTL(fd, cmd, arg) \
+ syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg))
+
+
+int media_ioctl_ctrl(struct media_device *media, int request,
+ struct v4l2_control *arg)
+{
+ struct media_entity *entity = media->pipeline;
+ struct v4l2_control ctrl = *arg;
+ struct v4l2_queryctrl queryctrl;
+ bool ctrl_found = 0;
+ int ret;
+
+ /*
+ * The control has to be reset to the default value
+ * on all of the pipeline entities, prior setting a new
+ * value. This is required in cases when the control config
+ * is changed between subsequent calls to VIDIOC_S_CTRL,
+ * to avoid the situation when a control is set on more
+ * than one sub-device.
+ */
+ if (request == VIDIOC_S_CTRL) {
+ while (entity) {
+ queryctrl.id = ctrl.id;
+
+ ret = SYS_IOCTL(entity->sd->fd, VIDIOC_QUERYCTRL,
+ &queryctrl);
+ if (ret < 0) {
+ entity = entity->next;
+ continue;
+ }
+
+ ctrl_found = true;
+
+ if (queryctrl.type & V4L2_CTRL_TYPE_BUTTON)
+ break;
+
+ ctrl.value = queryctrl.default_value;
+ ret = SYS_IOCTL(entity->sd->fd, VIDIOC_S_CTRL, &ctrl);
+ if (ret < 0)
+ return -EINVAL;
+
+ entity = entity->next;
+ }
+
+ ctrl.value = arg->value;
+ }
+
+ if (!ctrl_found) {
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ entity = v4l2_subdev_get_pipeline_entity_by_cid(media, ctrl.id);
+ if (entity) {
+ ret = SYS_IOCTL(entity->sd->fd, request, &ctrl);
+ goto exit;
+ }
+
+ /* Walk the pipeline until the request succeeds */
+ entity = media->pipeline;
+
+ ret = -ENOENT;
+
+ while (entity) {
+ ret = SYS_IOCTL(entity->sd->fd, request, &ctrl);
+ if (!ret)
+ goto exit;
+
+ entity = entity->next;
+ }
+
+exit:
+ *arg = ctrl;
+
+ media_dbg(media, "%s [id: 0x%8.8x, entity: %s] (%d)\n",
+ VIDIOC_CTRL(request), ctrl.id,
+ entity ? entity->info.name : NULL, ret);
+
+ return ret;
+}
+
+static int media_ioctl_single_ext_ctrl(struct media_device *media,
+ int request, struct v4l2_ext_controls *arg)
+{
+ struct media_entity *entity = media->pipeline;
+ struct v4l2_ext_controls ctrls = *arg;
+ struct v4l2_ext_control *ctrl;
+ struct v4l2_query_ext_ctrl queryctrl;
+ bool ctrl_found = 0;
+ int ret = -EINVAL;
+
+ ctrl = &ctrls.controls[0];
+
+ /*
+ * The control has to be reset to the default value
+ * on all of the pipeline entities, prior setting a new
+ * value. This is required in cases when the control config
+ * is changed between subsequent calls to VIDIOC_S_EXT_CTRLS,
+ * to avoid the situation when a control is set on more
+ * than one sub-device.
+ */
+ if (request == VIDIOC_S_EXT_CTRLS) {
+ while (entity) {
+ queryctrl.id = ctrl->id;
+
+ ret = SYS_IOCTL(entity->sd->fd, VIDIOC_QUERY_EXT_CTRL,
+ &queryctrl);
+ if (ret < 0) {
+ entity = entity->next;
+ continue;
+ }
+
+ ctrl_found = true;
+
+ if (queryctrl.type & V4L2_CTRL_TYPE_BUTTON)
+ break;
+
+ ctrl->value64 = queryctrl.default_value;
+
+ ret = SYS_IOCTL(entity->sd->fd, VIDIOC_S_EXT_CTRLS,
+ &ctrls);
+ if (ret < 0)
+ return -EINVAL;
+
+ entity = entity->next;
+ }
+
+ ctrl->value64 = arg->controls[0].value64;
+ }
+
+ if (!ctrl_found) {
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ entity = v4l2_subdev_get_pipeline_entity_by_cid(media, ctrl->id);
+ if (entity) {
+ ret = SYS_IOCTL(entity->sd->fd, request, &ctrls);
+ goto exit;
+ }
+
+ /* Walk the pipeline until the request succeeds */
+ entity = media->pipeline;
+
+ while (entity) {
+ ret = SYS_IOCTL(entity->sd->fd, request, &ctrls);
+ if (!ret)
+ goto exit;
+
+ entity = entity->next;
+ }
+
+exit:
+ *arg = ctrls;
+
+ media_dbg(media, "%s [id: 0x%8.8x, entity: %s] (%d)\n",
+ VIDIOC_EXT_CTRL(request), ctrl->id,
+ entity ? entity->info.name : NULL, ret);
+
+ return ret;
+}
+
+int media_ioctl_ext_ctrl(struct media_device *media, int request,
+ struct v4l2_ext_controls *arg)
+{
+ struct v4l2_ext_controls out_ctrls = *arg, ctrls = *arg;
+ int ret = -EINVAL, i;
+
+ ctrls.count = 1;
+
+ /*
+ * Split cluster to individual ioctl calls for each control
+ * from the array, to make possible redirection of every
+ * single control to different sub-device, according to the
+ * configuration settings.
+ */
+ for (i = 0; i < arg->count; ++i) {
+ ctrls.controls = &arg->controls[i];
+
+ ret = media_ioctl_single_ext_ctrl(media, request, &ctrls);
+ out_ctrls.controls[i] = ctrls.controls[i];
+ if (ret < 0) {
+ if (ctrls.error_idx == 1)
+ out_ctrls.error_idx = ctrls.count;
+ else
+ out_ctrls.error_idx = i;
+ goto exit;
+ }
+ }
+
+exit:
+ *arg = out_ctrls;
+ return ret;
+}
+
+int media_ioctl_queryctrl(struct media_device *media,
+ struct v4l2_queryctrl *arg)
+{
+ struct media_entity *entity = media->pipeline, *target_entity;
+ struct v4l2_queryctrl queryctrl = *arg;
+ int ret = -EINVAL;
+
+ while (entity) {
+ ret = SYS_IOCTL(entity->sd->fd, VIDIOC_QUERYCTRL, &queryctrl);
+ if (!ret) {
+ /*
+ * Control id might be or'ed with V4L2_CTRL_FLAG_NEXT_CTRL,
+ * therefore the check for the config settings must be
+ * done no sooner than after first successful ioctl execution
+ * on a pipeline sub-device.
+ */
+ target_entity =
+ v4l2_subdev_get_pipeline_entity_by_cid(media,
+ queryctrl.id);
+ /*
+ * If the control is in the config, then
+ * query the associated sub-device.
+ */
+ if (target_entity) {
+ /*
+ * It might happen that pipeline head is the
+ * target entity for the control - in such a
+ * case preclude requering it.
+ */
+ if (target_entity != entity)
+ ret = SYS_IOCTL(target_entity->sd->fd,
+ VIDIOC_QUERYCTRL,
+ &queryctrl);
+ entity = target_entity;
+ }
+
+ break;
+ }
+
+ entity = entity->next;
+ }
+
+ *arg = queryctrl;
+
+ media_dbg(media,
+ "VIDIOC_QUERYCTRL [id: 0x%8.8x, entity: %s] (%d)\n",
+ queryctrl.id, entity ? entity->info.name : NULL, ret);
+
+ return ret;
+}
+
+int media_ioctl_query_ext_ctrl(struct media_device *media,
+ struct v4l2_query_ext_ctrl *arg)
+{
+ struct media_entity *entity = media->pipeline, *target_entity;
+ struct v4l2_query_ext_ctrl query_ext_ctrl = *arg;
+ int ret = -EINVAL;
+
+ while (entity) {
+ ret = SYS_IOCTL(entity->sd->fd, VIDIOC_QUERY_EXT_CTRL,
+ &query_ext_ctrl);
+ if (!ret) {
+ /*
+ * Passed query_ext_ctrl.id id might be or'ed with
+ * V4L2_CTRL_FLAG_NEXT_CTRL, therefore the check for
+ * existence of the related configuration must be
+ * done no sooner than after first successful ioctl
+ * execution on a pipeline sub-device.
+ */
+ target_entity =
+ v4l2_subdev_get_pipeline_entity_by_cid(media,
+ query_ext_ctrl.id);
+ /*
+ * If the control is in the config, then
+ * query the associated sub-device.
+ */
+ if (target_entity) {
+ /*
+ * It might happen that pipeline head is the
+ * target entity for the control - in such a
+ * case preclude requering it.
+ */
+ if (target_entity != entity)
+ ret = SYS_IOCTL(target_entity->sd->fd,
+ VIDIOC_QUERY_EXT_CTRL,
+ &query_ext_ctrl);
+ entity = target_entity;
+ }
+
+ break;
+ }
+
+ entity = entity->next;
+ }
+
+ *arg = query_ext_ctrl;
+
+ media_dbg(media,
+ "VIDIOC_QUERY_EXT_CTRL [id: 0x%8.8x, entity: %s] (%d)\n",
+ query_ext_ctrl.id, entity ? entity->info.name : NULL, ret);
+
+ return ret;
+}
+
+int media_ioctl_querymenu(struct media_device *media,
+ struct v4l2_querymenu *arg)
+{
+ struct media_entity *entity = media->pipeline;
+ struct v4l2_querymenu querymenu = *arg;
+ int ret = -EINVAL;
+
+ entity = v4l2_subdev_get_pipeline_entity_by_cid(media, querymenu.id);
+ if (entity) {
+ ret = SYS_IOCTL(entity->sd->fd, VIDIOC_QUERYMENU, &querymenu);
+ goto exit;
+ }
+
+ entity = media->pipeline;
+
+ while (entity) {
+ ret = SYS_IOCTL(entity->sd->fd, VIDIOC_QUERYMENU, &querymenu);
+ if (!ret)
+ goto exit;
+
+ entity = entity->next;
+ }
+
+exit:
+ *arg = querymenu;
+
+ media_dbg(media, "VIDIOC_QUERYMENU [id: 0x%8.8x, entity: %s] (%d)\n",
+ querymenu.id, entity ? entity->info.name : NULL, ret);
+
+ return ret;
+}
diff --git a/utils/media-ctl/libv4l2media_ioctl.h b/utils/media-ctl/libv4l2media_ioctl.h
new file mode 100644
index 0000000..2841c09
--- /dev/null
+++ b/utils/media-ctl/libv4l2media_ioctl.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski <j.anaszewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+
+#ifndef __LIBV4L2MEDIA_IOCTL_H
+#define __LIBV4L2MEDIA_IOCTL_H
+
+#include <linux/videodev2.h>
+
+struct media_device;
+
+int media_ioctl_ctrl(struct media_device *media, int request,
+ struct v4l2_control *arg);
+
+int media_ioctl_ext_ctrl(struct media_device *media, int request,
+ struct v4l2_ext_controls *arg);
+
+int media_ioctl_queryctrl(struct media_device *media,
+ struct v4l2_queryctrl *arg);
+
+int media_ioctl_query_ext_ctrl(struct media_device *media,
+ struct v4l2_query_ext_ctrl *arg);
+
+int media_ioctl_querymenu(struct media_device *media,
+ struct v4l2_querymenu *arg);
+
+#endif /* __LIBV4L2MEDIA_IOCTL_H */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 13/14] mediactl: libv4l2subdev: Enable opening/closing pipelines
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (11 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 12/14] mediactl: Add media device ioctl API Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 14/14] Add a libv4l plugin for Exynos4 camera Jacek Anaszewski
2015-06-08 8:27 ` [v4l-utils PATCH/RFC v5 00/14] Add a " Hans Verkuil
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
Add functions for opening and closing media entity pipelines
at one go.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
utils/media-ctl/libv4l2subdev.c | 60 +++++++++++++++++++++++++++++++++++++++
utils/media-ctl/v4l2subdev.h | 18 ++++++++++++
2 files changed, 78 insertions(+)
diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c
index 379fe64..4475ef7 100644
--- a/utils/media-ctl/libv4l2subdev.c
+++ b/utils/media-ctl/libv4l2subdev.c
@@ -117,6 +117,66 @@ void v4l2_subdev_close(struct media_entity *entity)
entity->sd->fd = -1;
}
+int v4l2_subdev_open_pipeline(struct media_device *media)
+{
+ struct media_entity *entity = media->pipeline;
+ int ret;
+
+ if (entity == NULL)
+ return 0;
+
+ /*
+ * Stop walking the pipeline on the last last but one entity, because
+ * the sink entity sub-device was opened by libv4l2 core and its
+ * file descriptor needs to be preserved.
+ */
+ while (entity->next) {
+ media_dbg(media, "Opening sub-device: %s\n", entity->devname);
+ ret = v4l2_subdev_open(entity);
+ if (ret < 0)
+ return ret;
+
+ if (entity->sd->fd < 0)
+ goto err_open_subdev;
+
+ entity = entity->next;
+ }
+
+ return 0;
+
+err_open_subdev:
+ v4l2_subdev_release_pipeline(media);
+
+ return -EINVAL;
+}
+
+void v4l2_subdev_release_pipeline(struct media_device *media)
+{
+ struct media_entity *entity = media->pipeline;
+
+ if (entity == NULL)
+ return;
+ /*
+ * Stop walking the pipeline on the last last but one entity, because
+ * the sink entity sub-device should be released by the client that
+ * instantiated it.
+ */
+ while (entity->next) {
+ if (!entity->sd) {
+ entity = entity->next;
+ continue;
+ }
+
+ if (entity->sd->fd >= 0) {
+ media_dbg(media, "Releasing sub-device: %s\n", entity->devname);
+ v4l2_subdev_release(entity, true);
+ }
+
+ entity = entity->next;
+ }
+}
+
+
int v4l2_subdev_get_format(struct media_entity *entity,
struct v4l2_mbus_framefmt *format, unsigned int pad,
enum v4l2_subdev_format_whence which)
diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h
index 0f1deca..2fdcb76 100644
--- a/utils/media-ctl/v4l2subdev.h
+++ b/utils/media-ctl/v4l2subdev.h
@@ -90,6 +90,24 @@ int v4l2_subdev_open(struct media_entity *entity);
void v4l2_subdev_close(struct media_entity *entity);
/**
+ * @brief Open media device pipeline
+ * @param media - media device.
+ *
+ * Open all sub-devices in the media device pipeline.
+ *
+ * @return 0 on success, or a negative error code on failure.
+ */
+int v4l2_subdev_open_pipeline(struct media_device *media);
+
+/**
+ * @brief Release media device pipeline sub-devices
+ * @param media - media device.
+ *
+ * Release all sub-devices in the media device pipeline.
+ */
+void v4l2_subdev_release_pipeline(struct media_device *media);
+
+/**
* @brief Retrieve the format on a pad.
* @param entity - subdev-device media entity.
* @param format - format to be filled.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [v4l-utils PATCH/RFC v5 14/14] Add a libv4l plugin for Exynos4 camera
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (12 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 13/14] mediactl: libv4l2subdev: Enable opening/closing pipelines Jacek Anaszewski
@ 2015-02-26 15:59 ` Jacek Anaszewski
2015-06-08 8:27 ` [v4l-utils PATCH/RFC v5 00/14] Add a " Hans Verkuil
14 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-02-26 15:59 UTC (permalink / raw)
To: linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park,
Jacek Anaszewski
The plugin provides support for the media device on Exynos4 SoC.
It performs single plane <-> multi plane API conversion,
video pipeline linking and takes care of automatic data format
negotiation for the whole pipeline, after intercepting
VIDIOC_S_FMT or VIDIOC_TRY_FMT ioctls.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
---
configure.ac | 1 +
lib/Makefile.am | 5 +
lib/libv4l-exynos4-camera/Makefile.am | 7 +
lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 586 +++++++++++++++++++++
4 files changed, 599 insertions(+)
create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
diff --git a/configure.ac b/configure.ac
index 85f71e0..fa3679f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,7 @@ AC_CONFIG_FILES([Makefile
lib/libdvbv5/Makefile
lib/libv4l2rds/Makefile
lib/libv4l-mplane/Makefile
+ lib/libv4l-exynos4-camera/Makefile
utils/Makefile
utils/libv4l2util/Makefile
diff --git a/lib/Makefile.am b/lib/Makefile.am
index ee0c3c5..56b3a9f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -5,6 +5,11 @@ SUBDIRS = \
libv4l2rds \
libv4l-mplane
+if WITH_V4LUTILS
+SUBDIRS += \
+ libv4l-exynos4-camera
+endif
+
if LINUX_OS
SUBDIRS += \
libdvbv5
diff --git a/lib/libv4l-exynos4-camera/Makefile.am b/lib/libv4l-exynos4-camera/Makefile.am
new file mode 100644
index 0000000..23c60c6
--- /dev/null
+++ b/lib/libv4l-exynos4-camera/Makefile.am
@@ -0,0 +1,7 @@
+if WITH_V4L_PLUGINS
+libv4l2plugin_LTLIBRARIES = libv4l-exynos4-camera.la
+endif
+
+libv4l_exynos4_camera_la_SOURCES = libv4l-exynos4-camera.c ../../utils/media-ctl/libmediactl.c ../../utils/media-ctl/libv4l2subdev.c ../../utils/media-ctl/libv4l2media_ioctl.c ../../utils/media-ctl/mediatext.c
+libv4l_exynos4_camera_la_CFLAGS = -fvisibility=hidden -std=gnu99
+libv4l_exynos4_camera_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -lpthread
diff --git a/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
new file mode 100644
index 0000000..29cfab2
--- /dev/null
+++ b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
@@ -0,0 +1,586 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski <j.anaszewski@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ */
+
+#include <config.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/syscall.h>
+#include <linux/types.h>
+
+#include "../../utils/media-ctl/libv4l2media_ioctl.h"
+#include "../../utils/media-ctl/mediactl.h"
+#include "../../utils/media-ctl/mediatext.h"
+#include "../../utils/media-ctl/v4l2subdev.h"
+#include "libv4l-plugin.h"
+
+struct media_device;
+struct media_entity;
+
+/*
+ * struct exynos4_camera_plugin - libv4l exynos4 camera plugin
+ * @media: media device comprising the vid_fd related video device
+ */
+struct exynos4_camera_plugin {
+ struct media_device *media;
+ struct media_entity *sink_entity;
+};
+
+#ifdef DEBUG
+#define V4L2_EXYNOS4_DBG(format, ARG...)\
+ printf("[%s:%d] [%s] " format " \n", __FILE__, __LINE__, __func__, ##ARG)
+#else
+#define V4L2_EXYNOS4_DBG(format, ARG...)
+#endif
+
+#define V4L2_EXYNOS4_ERR(format, ARG...)\
+ fprintf(stderr, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG)
+
+#define V4L2_EXYNOS4_LOG(format, ARG...)\
+ fprintf(stdout, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG)
+
+#if HAVE_VISIBILITY
+#define PLUGIN_PUBLIC __attribute__ ((visibility("default")))
+#else
+#define PLUGIN_PUBLIC
+#endif
+
+#define SYS_IOCTL(fd, cmd, arg) \
+ syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg))
+
+#define SIMPLE_CONVERT_IOCTL(fd, cmd, arg, __struc) ({ \
+ int __ret; \
+ struct __struc *req = arg; \
+ uint32_t type = req->type; \
+ req->type = convert_type(type); \
+ __ret = SYS_IOCTL(fd, cmd, arg); \
+ req->type = type; \
+ __ret; \
+ })
+
+#define EXYNOS4_FIMC_DRV "exynos4-fimc"
+#define EXYNOS4_FIMC_LITE_DRV "exynos-fimc-lit"
+#define EXYNOS4_FIMC_IS_ISP_DRV "exynos4-fimc-is"
+#define ENTITY_CAPTURE_SEGMENT "capture"
+#define EXYNOS4_CAPTURE_CONF "/var/lib/libv4l/exynos4_capture_conf"
+#define EXYNOS4_FIMC_IS_ISP "FIMC-IS-ISP"
+#define EXYNOS4_FIMC_PREFIX "FIMC."
+#define MAX_FMT_NEGO_NUM 50
+
+
+static int __capture_entity(const char *name)
+{
+ int cap_segment_pos;
+
+ if (name == NULL)
+ return 0;
+
+ cap_segment_pos = strlen(name) - strlen(ENTITY_CAPTURE_SEGMENT);
+
+ if (strcmp(name + cap_segment_pos, ENTITY_CAPTURE_SEGMENT) == 0)
+ return 1;
+
+ return 0;
+}
+
+static int __adjust_format_to_fimc_is_isp(struct v4l2_mbus_framefmt *mbus_fmt)
+{
+ if (mbus_fmt == NULL)
+ return -EINVAL;
+
+ mbus_fmt->width += 16;
+ mbus_fmt->height += 12;
+
+ return 0;
+}
+
+static int negotiate_pipeline_fmt(struct media_entity *pipeline,
+ struct v4l2_format *dev_fmt)
+{
+ struct media_entity *entity = pipeline;
+ struct v4l2_subdev_format subdev_fmt = { 0 };
+ struct v4l2_mbus_framefmt mbus_fmt = { 0 }, common_fmt;
+ int repeat_negotiation, cnt_negotiation = 0, ret, pad_id;
+
+ if (pipeline == NULL || dev_fmt == NULL)
+ return -EINVAL;
+
+ mbus_fmt.width = dev_fmt->fmt.pix_mp.width;
+ mbus_fmt.height = dev_fmt->fmt.pix_mp.height;
+ mbus_fmt.field = dev_fmt->fmt.pix_mp.field;
+ mbus_fmt.colorspace = dev_fmt->fmt.pix_mp.colorspace;
+
+ if (media_has_pipeline_entity(entity, EXYNOS4_FIMC_IS_ISP)) {
+ ret = __adjust_format_to_fimc_is_isp(&mbus_fmt);
+ if (ret < 0)
+ return ret;
+ }
+
+ V4L2_EXYNOS4_DBG("Begin pipeline format negotiation...");
+
+ for (;;) {
+ repeat_negotiation = 0;
+ entity = pipeline;
+
+ pad_id = media_entity_get_src_pad_index(entity);
+
+ V4L2_EXYNOS4_DBG("Setting format on entity %s, pad: %d",
+ media_entity_get_name(entity), pad_id);
+
+ ret = v4l2_subdev_set_format(entity, &mbus_fmt,
+ pad_id, V4L2_SUBDEV_FORMAT_TRY);
+ if (ret < 0)
+ return ret;
+
+ common_fmt = mbus_fmt;
+
+ entity = media_entity_get_next(entity);
+
+ while (entity) {
+ pad_id = media_entity_get_sink_pad_index(entity);
+
+ /* Set format on the entity src pad */
+ V4L2_EXYNOS4_DBG("Setting format on the entity pad %s:%d: mbus_code: %s, width: %d, height: %d",
+ media_entity_get_name(entity), pad_id,
+ v4l2_subdev_pixelcode_to_string(mbus_fmt.code),
+ mbus_fmt.width, mbus_fmt.height);
+
+ ret = v4l2_subdev_set_format(entity, &mbus_fmt, pad_id,
+ V4L2_SUBDEV_FORMAT_TRY);
+ if (ret < 0)
+ return ret;
+
+ if (!v4l2_subdev_format_compare(&mbus_fmt, &common_fmt)) {
+ repeat_negotiation = 1;
+ break;
+ }
+
+ /*
+ * Do not check format on FIMC.[n] source pad
+ * and stop negotiation.
+ */
+ if (!strncmp(media_entity_get_name(entity),
+ EXYNOS4_FIMC_PREFIX,
+ strlen(EXYNOS4_FIMC_PREFIX)))
+ break;
+
+ pad_id = media_entity_get_src_pad_index(entity);
+
+ /* Get format on the entity sink pad */
+ ret = v4l2_subdev_get_format(entity, &mbus_fmt, pad_id,
+ V4L2_SUBDEV_FORMAT_TRY);
+ if (ret < 0)
+ return -EINVAL;
+
+ V4L2_EXYNOS4_DBG("Format propagated to the entity pad %s:%d: mbus_code: %s, width: %d, height: %d",
+ media_entity_get_name(entity), pad_id,
+ v4l2_subdev_pixelcode_to_string(mbus_fmt.code),
+ mbus_fmt.width, mbus_fmt.height);
+
+ if (!strcmp(media_entity_get_name(entity),
+ EXYNOS4_FIMC_IS_ISP)) {
+ common_fmt.code = subdev_fmt.format.code;
+ common_fmt.colorspace =
+ subdev_fmt.format.colorspace;
+ common_fmt.width -= 16;
+ common_fmt.height -= 12;
+ }
+
+ if (!v4l2_subdev_format_compare(&mbus_fmt, &common_fmt)) {
+ repeat_negotiation = 1;
+ break;
+ }
+
+ entity = media_entity_get_next(entity);
+
+ /*
+ * Stop if this is last element in the
+ * pipeline as it is not a sub-device.
+ */
+ if (media_entity_get_next(entity) == NULL)
+ break;
+ }
+
+ if (!repeat_negotiation) {
+ break;
+ } else if (++cnt_negotiation > MAX_FMT_NEGO_NUM) {
+ V4L2_EXYNOS4_DBG("Pipeline format negotiation failed!");
+ return -EINVAL;
+ }
+ }
+
+ dev_fmt->fmt.pix_mp.width = mbus_fmt.width;
+ dev_fmt->fmt.pix_mp.height = mbus_fmt.height;
+ dev_fmt->fmt.pix_mp.field = mbus_fmt.field;
+ dev_fmt->fmt.pix_mp.colorspace = mbus_fmt.colorspace;
+
+ V4L2_EXYNOS4_DBG("Pipeline format successfuly negotiated");
+
+ return 0;
+}
+
+static __u32 convert_type(__u32 type)
+{
+ switch (type) {
+ case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+ return V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
+ default:
+ return type;
+ }
+}
+
+static int set_fmt_ioctl(struct media_device *media,
+ unsigned long int cmd,
+ struct v4l2_format *arg,
+ enum v4l2_subdev_format_whence set_mode)
+{
+ struct v4l2_format fmt = { 0 };
+ int ret;
+
+ fmt.type = convert_type(arg->type);
+ if (fmt.type != arg->type) {
+ fmt.fmt.pix_mp.width = arg->fmt.pix.width;
+ fmt.fmt.pix_mp.height = arg->fmt.pix.height;
+ fmt.fmt.pix_mp.pixelformat = arg->fmt.pix.pixelformat;
+ fmt.fmt.pix_mp.field = arg->fmt.pix.field;
+ fmt.fmt.pix_mp.colorspace = arg->fmt.pix.colorspace;
+ fmt.fmt.pix_mp.num_planes = 1;
+ fmt.fmt.pix_mp.flags = arg->fmt.pix.flags;
+ fmt.fmt.pix_mp.plane_fmt[0].bytesperline = arg->fmt.pix.bytesperline;
+ fmt.fmt.pix_mp.plane_fmt[0].sizeimage = arg->fmt.pix.sizeimage;
+ } else {
+ fmt = *arg;
+ }
+
+ ret = negotiate_pipeline_fmt(media_get_pipeline(media), &fmt);
+ if (ret < 0)
+ return ret;
+
+ if (set_mode == V4L2_SUBDEV_FORMAT_ACTIVE) {
+ ret = v4l2_subdev_apply_pipeline_fmt(media, &fmt);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (fmt.type != arg->type) {
+ arg->fmt.pix.width = fmt.fmt.pix_mp.width;
+ arg->fmt.pix.height = fmt.fmt.pix_mp.height;
+ arg->fmt.pix.pixelformat = fmt.fmt.pix_mp.pixelformat;
+ arg->fmt.pix.field = fmt.fmt.pix_mp.field;
+ arg->fmt.pix.colorspace = fmt.fmt.pix_mp.colorspace;
+ arg->fmt.pix.bytesperline = fmt.fmt.pix_mp.plane_fmt[0].bytesperline;
+ arg->fmt.pix.sizeimage = fmt.fmt.pix_mp.plane_fmt[0].sizeimage;
+ arg->fmt.pix.flags = fmt.fmt.pix_mp.flags;
+ } else {
+ *arg = fmt;
+ }
+
+ return 0;
+}
+
+static int get_fmt_ioctl(int fd,
+ unsigned long int cmd,
+ struct v4l2_format *arg)
+{
+ struct v4l2_format fmt = { 0 };
+ int ret;
+
+ fmt.type = convert_type(arg->type);
+
+ if (fmt.type == arg->type)
+ return SYS_IOCTL(fd, cmd, arg);
+
+ ret = SYS_IOCTL(fd, cmd, &fmt);
+ if (ret < 0)
+ return ret;
+
+ memset(&arg->fmt.pix, 0, sizeof(arg->fmt.pix));
+ arg->fmt.pix.width = fmt.fmt.pix_mp.width;
+ arg->fmt.pix.height = fmt.fmt.pix_mp.height;
+ arg->fmt.pix.pixelformat = fmt.fmt.pix_mp.pixelformat;
+ arg->fmt.pix.field = fmt.fmt.pix_mp.field;
+ arg->fmt.pix.colorspace = fmt.fmt.pix_mp.colorspace;
+ arg->fmt.pix.bytesperline = fmt.fmt.pix_mp.plane_fmt[0].bytesperline;
+ arg->fmt.pix.sizeimage = fmt.fmt.pix_mp.plane_fmt[0].sizeimage;
+ arg->fmt.pix.flags = fmt.fmt.pix_mp.flags;
+
+ return ret;
+}
+
+static int buf_ioctl(int fd,
+ unsigned long int cmd,
+ struct v4l2_buffer *arg)
+{
+ struct v4l2_buffer buf = *arg;
+ struct v4l2_plane plane = { 0 };
+ int ret;
+
+ buf.type = convert_type(arg->type);
+
+ if (buf.type == arg->type)
+ return SYS_IOCTL(fd, cmd, arg);
+
+ memcpy(&plane.m, &arg->m, sizeof(plane.m));
+ plane.length = arg->length;
+ plane.bytesused = arg->bytesused;
+
+ buf.m.planes = &plane;
+ buf.length = 1;
+
+ ret = SYS_IOCTL(fd, cmd, &buf);
+
+ arg->index = buf.index;
+ arg->memory = buf.memory;
+ arg->flags = buf.flags;
+ arg->field = buf.field;
+ arg->timestamp = buf.timestamp;
+ arg->timecode = buf.timecode;
+ arg->sequence = buf.sequence;
+
+ arg->length = plane.length;
+ arg->bytesused = plane.bytesused;
+ memcpy(&arg->m, &plane.m, sizeof(arg->m));
+
+ return ret;
+}
+
+static int querycap_ioctl(int fd, struct v4l2_capability *arg)
+{
+ int ret;
+
+ ret = SYS_IOCTL(fd, VIDIOC_QUERYCAP, arg);
+ if (ret < 0)
+ return ret;
+
+ arg->device_caps |= V4L2_CAP_VIDEO_CAPTURE;
+ arg->capabilities |= V4L2_CAP_VIDEO_CAPTURE;
+
+ return ret;
+}
+
+static void *plugin_init(int fd)
+{
+ struct v4l2_capability cap = { 0 };
+ struct exynos4_camera_plugin *plugin = NULL;
+ const char *sink_entity_name;
+ struct media_device *media;
+ struct media_entity *sink_entity;
+ char video_devname[32];
+ int ret;
+
+ ret = SYS_IOCTL(fd, VIDIOC_QUERYCAP, &cap);
+ if (ret < 0) {
+ V4L2_EXYNOS4_ERR("Failed to query video capabilities.");
+ return NULL;
+ }
+
+ /* Check if this is Exynos4 media device */
+ if (strcmp((char *) cap.driver, EXYNOS4_FIMC_DRV) &&
+ strcmp((char *) cap.driver, EXYNOS4_FIMC_LITE_DRV) &&
+ strcmp((char *) cap.driver, EXYNOS4_FIMC_IS_ISP_DRV)) {
+ V4L2_EXYNOS4_ERR("Not an Exynos4 media device.");
+ return NULL;
+ }
+
+ /* Obtain the node name of the opened device */
+ ret = media_get_devname_by_fd(fd, video_devname);
+ if (ret < 0) {
+ V4L2_EXYNOS4_ERR("Failed to get video device node name.");
+ return NULL;
+ }
+
+ /*
+ * Create the representation of a media device
+ * containing the opened video device.
+ */
+ media = media_device_new_by_entity_devname(video_devname);
+ if (media == NULL) {
+ V4L2_EXYNOS4_ERR("Failed to create media device.");
+ return NULL;
+ }
+
+#ifdef DEBUG
+ media_debug_set_handler(media, (void (*)(void *, ...))fprintf, stdout);
+#endif
+
+ /* Get the entity representing the opened video device node */
+ sink_entity = media_get_entity_by_devname(media, video_devname,
+ strlen(video_devname));
+ if (sink_entity == NULL) {
+ V4L2_EXYNOS4_ERR("Failed to get sink entity name.");
+ goto err_get_sink_entity;
+ }
+
+ /*
+ * Initialize sink_entity subdev fd with the one opened
+ * by the libv4l core to avoid losing it on pipeline opening.
+ */
+ v4l2_subdev_create_with_fd(sink_entity, fd);
+
+ sink_entity_name = media_entity_get_name(sink_entity);
+
+ /* Check if video entity is of capture type, not m2m */
+ if (!__capture_entity(sink_entity_name)) {
+ V4L2_EXYNOS4_ERR("Device not of capture type.");
+ goto err_get_sink_entity;
+ }
+
+ V4L2_EXYNOS4_ERR("before parsing");
+ /* Parse media configuration file and apply its settings */
+ ret = mediatext_parse_setup_config(media, EXYNOS4_CAPTURE_CONF);
+ if (ret < 0) {
+ V4L2_EXYNOS4_ERR("Media config parser error.");
+ goto err_get_sink_entity;
+ }
+
+ /*
+ * Discover the pipeline of sub-devices from a camera sensor
+ * to the opened video device.
+ */
+ ret = media_discover_pipeline_by_entity(media, sink_entity);
+ if (ret < 0) {
+ V4L2_EXYNOS4_ERR("Error discovering video pipeline.");
+ goto err_get_sink_entity;
+ }
+
+ /* Open all sub-devices in the discovered pipeline */
+ ret = v4l2_subdev_open_pipeline(media);
+ if (ret < 0) {
+ V4L2_EXYNOS4_ERR("Error opening video pipeline.");
+ goto err_get_sink_entity;
+ }
+
+ /* Allocate private data */
+ plugin = calloc(1, sizeof(*plugin));
+ if (!plugin)
+ goto err_validate_controls;
+
+ plugin->media = media;
+ plugin->sink_entity = sink_entity;
+
+ V4L2_EXYNOS4_LOG("Initialized exynos4-camera plugin.");
+
+ return plugin;
+
+err_validate_controls:
+ v4l2_subdev_release(sink_entity, false);
+ v4l2_subdev_release_pipeline(media);
+err_get_sink_entity:
+ if (media)
+ media_device_unref(media);
+ return NULL;
+}
+
+static void plugin_close(void *dev_ops_priv)
+{
+ struct exynos4_camera_plugin *plugin = dev_ops_priv;
+ struct media_device *media;
+
+ if (plugin == NULL)
+ return;
+
+ /* release sink entity sub-device, but don't close fd */
+ v4l2_subdev_release(plugin->sink_entity, false);
+
+ media = plugin->media;
+ v4l2_subdev_release_pipeline(media);
+ media_device_unref(media);
+
+ free(plugin);
+}
+
+static int plugin_ioctl(void *dev_ops_priv, int fd, unsigned long int cmd,
+ void *arg)
+{
+ struct exynos4_camera_plugin *plugin = dev_ops_priv;
+ struct media_device *media;
+
+ if (plugin == NULL || arg == NULL)
+ return -EINVAL;
+
+ media = plugin->media;
+
+ if (media == NULL)
+ return -EINVAL;
+
+ switch (cmd) {
+ case VIDIOC_S_CTRL:
+ case VIDIOC_G_CTRL:
+ return media_ioctl_ctrl(media, cmd, arg);
+ case VIDIOC_S_EXT_CTRLS:
+ case VIDIOC_G_EXT_CTRLS:
+ case VIDIOC_TRY_EXT_CTRLS:
+ return media_ioctl_ext_ctrl(media, cmd, arg);
+ case VIDIOC_QUERYCTRL:
+ return media_ioctl_queryctrl(media, arg);
+ case VIDIOC_QUERY_EXT_CTRL:
+ return media_ioctl_query_ext_ctrl(media, arg);
+ case VIDIOC_QUERYMENU:
+ return media_ioctl_querymenu(media, arg);
+ case VIDIOC_TRY_FMT:
+ return set_fmt_ioctl(media, cmd, arg,
+ V4L2_SUBDEV_FORMAT_TRY);
+ case VIDIOC_S_FMT:
+ return set_fmt_ioctl(media, cmd, arg,
+ V4L2_SUBDEV_FORMAT_ACTIVE);
+ case VIDIOC_G_FMT:
+ return get_fmt_ioctl(fd, cmd, arg);
+ case VIDIOC_QUERYCAP:
+ return querycap_ioctl(fd, arg);
+ case VIDIOC_QBUF:
+ case VIDIOC_DQBUF:
+ case VIDIOC_QUERYBUF:
+ case VIDIOC_PREPARE_BUF:
+ return buf_ioctl(fd, cmd, arg);
+ case VIDIOC_REQBUFS:
+ return SIMPLE_CONVERT_IOCTL(fd, cmd, arg,
+ v4l2_requestbuffers);
+ case VIDIOC_ENUM_FMT:
+ return SIMPLE_CONVERT_IOCTL(fd, cmd, arg, v4l2_fmtdesc);
+ case VIDIOC_CROPCAP:
+ return SIMPLE_CONVERT_IOCTL(fd, cmd, arg, v4l2_cropcap);
+ case VIDIOC_STREAMON:
+ case VIDIOC_STREAMOFF:
+ {
+ int *arg_type = (int *) arg;
+ __u32 type;
+
+ type = convert_type(*arg_type);
+
+ if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
+ type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+ V4L2_EXYNOS4_ERR("Invalid buffer type.");
+ return -EINVAL;
+ }
+
+ return SYS_IOCTL(fd, cmd, &type);
+ }
+
+ default:
+ return SYS_IOCTL(fd, cmd, arg);
+ }
+}
+
+PLUGIN_PUBLIC const struct libv4l_dev_ops libv4l2_plugin = {
+ .init = &plugin_init,
+ .close = &plugin_close,
+ .ioctl = &plugin_ioctl,
+};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
` (13 preceding siblings ...)
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 14/14] Add a libv4l plugin for Exynos4 camera Jacek Anaszewski
@ 2015-06-08 8:27 ` Hans Verkuil
2015-06-08 9:14 ` Jacek Anaszewski
14 siblings, 1 reply; 19+ messages in thread
From: Hans Verkuil @ 2015-06-08 8:27 UTC (permalink / raw)
To: Jacek Anaszewski, linux-media
Cc: sakari.ailus, laurent.pinchart, gjasny, hdegoede, kyungmin.park
Hi Jacek,
What is the status of this? It would be really useful to have a working plugin
as an example in v4l-utils.
Regards,
Hans
On 02/26/2015 04:59 PM, Jacek Anaszewski wrote:
> This is a fifth version of the patch series adding a plugin for the
> Exynos4 camera.
>
> Temporarily the plugin doesn't link against libmediactl, but
> has its sources compiled in. Currently utils are built after
> the plugins, but libv4l-exynos4-camera plugin depends on the utils.
> In order to link the plugin against libmediactl the build system
> would have to be modified.
>
> ================
> Changes from v4:
> ================
>
> - removed some redundant functions for traversing media device graph
> and switched over to using existing ones
> - avoided accessing struct v4l2_subdev from libmediactl
> - applied various improvements
>
> ================
> Changes from v3:
> ================
>
> - added struct v4l2_subdev and put entity fd and
> information about supported controls to it
> - improved functions for negotiating and setting
> pipeline format by using available libv4lsubdev API
> - applied minor improvements and cleanups
>
> ================
> Changes from v2:
> ================
>
> - switched to using mediatext library for parsing
> the media device configuration
> - extended libmediactl
> - switched to using libmediactl
>
> ================
> Changes from v1:
> ================
>
> - removed redundant mbus code negotiation
> - split the parser, media device helpers and ioctl wrappers
> to the separate modules
> - added mechanism for querying extended controls
> - applied various fixes and modifications
>
> The plugin was tested on linux-next_20150223 with patches for
> exynos4-is that fix failing open ioctl when a sensor sub-device is not
> linked [1] [2] [3].
>
> The plugin expects a configuration file:
> /var/lib/libv4l/exynos4_capture_conf
>
> Exemplary configuration file:
>
> ==========================================
>
> link-conf "s5p-mipi-csis.0":1 -> "FIMC.0":0 [1]
> ctrl-to-subdev-conf 0x0098091f -> "fimc.0.capture"
> ctrl-to-subdev-conf 0x00980902 -> "S5C73M3"
> ctrl-to-subdev-conf 0x00980922 -> "fimc.0.capture"
> ctrl-to-subdev-conf 0x009a0914 -> "S5C73M3"
>
> ==========================================
>
> With this settings the plugin can be tested on the exynos4412-trats2 board
> using following gstreamer pipeline:
>
> gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=960,height=720 ! fbdevsink
>
> Thanks,
> Jacek Anaszewski
>
> [1] https://patchwork.linuxtv.org/patch/26366/
> [2] https://patchwork.linuxtv.org/patch/26367/
> [3] https://patchwork.linuxtv.org/patch/26368/
>
> Jacek Anaszewski (13):
> mediactl: Introduce v4l2_subdev structure
> mediactl: Add support for v4l2-ctrl-redir config
> mediatext: Add library
> mediactl: Add media device graph helpers
> mediactl: Add media_device creation helpers
> mediactl: libv4l2subdev: add VYUY8_2X8 mbus code
> mediactl: Add support for media device pipelines
> mediactl: libv4l2subdev: add support for comparing mbus formats
> mediactl: libv4l2subdev: add support for setting pipeline format
> mediactl: libv4l2subdev: add get_pipeline_entity_by_cid function
> mediactl: Add media device ioctl API
> mediactl: libv4l2subdev: Enable opening/closing pipelines
> Add a libv4l plugin for Exynos4 camera
>
> Sakari Ailus (1):
> mediactl: Separate entity and pad parsing
>
> configure.ac | 1 +
> lib/Makefile.am | 5 +
> lib/libv4l-exynos4-camera/Makefile.am | 7 +
> lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 586 +++++++++++++++++++++
> utils/media-ctl/Makefile.am | 12 +-
> utils/media-ctl/libmediactl.c | 271 +++++++++-
> utils/media-ctl/libmediatext.pc.in | 10 +
> utils/media-ctl/libv4l2media_ioctl.c | 369 +++++++++++++
> utils/media-ctl/libv4l2media_ioctl.h | 40 ++
> utils/media-ctl/libv4l2subdev.c | 301 ++++++++++-
> utils/media-ctl/mediactl-priv.h | 11 +-
> utils/media-ctl/mediactl.h | 151 ++++++
> utils/media-ctl/mediatext-test.c | 64 +++
> utils/media-ctl/mediatext.c | 311 +++++++++++
> utils/media-ctl/mediatext.h | 52 ++
> utils/media-ctl/v4l2subdev.h | 131 +++++
> 16 files changed, 2292 insertions(+), 30 deletions(-)
> create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
> create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
> create mode 100644 utils/media-ctl/libmediatext.pc.in
> create mode 100644 utils/media-ctl/libv4l2media_ioctl.c
> create mode 100644 utils/media-ctl/libv4l2media_ioctl.h
> create mode 100644 utils/media-ctl/mediatext-test.c
> create mode 100644 utils/media-ctl/mediatext.c
> create mode 100644 utils/media-ctl/mediatext.h
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera
2015-06-08 8:27 ` [v4l-utils PATCH/RFC v5 00/14] Add a " Hans Verkuil
@ 2015-06-08 9:14 ` Jacek Anaszewski
2015-06-08 9:36 ` Hans Verkuil
0 siblings, 1 reply; 19+ messages in thread
From: Jacek Anaszewski @ 2015-06-08 9:14 UTC (permalink / raw)
To: Hans Verkuil
Cc: linux-media, sakari.ailus, laurent.pinchart, gjasny, hdegoede,
kyungmin.park
Hi Hans,
It got stuck on this version. I have some slight improvements locally
but haven't sent them as there hasn't been any comment to this so far.
AFAIR Sakari had some doubts about handling multiple pipelines within
one media controller. In this approach only one pipeline is allowed.
There has to be a new IOCTL added for locking pipelines, to handle this
IIRC.
Besides there are some v4l-utils build system dependency issues to
solve, I mentioned below in the cover letter.
On 06/08/2015 10:27 AM, Hans Verkuil wrote:
> Hi Jacek,
>
> What is the status of this? It would be really useful to have a working plugin
> as an example in v4l-utils.
>
> Regards,
>
> Hans
>
> On 02/26/2015 04:59 PM, Jacek Anaszewski wrote:
>> This is a fifth version of the patch series adding a plugin for the
>> Exynos4 camera.
>>
>> Temporarily the plugin doesn't link against libmediactl, but
>> has its sources compiled in. Currently utils are built after
>> the plugins, but libv4l-exynos4-camera plugin depends on the utils.
>> In order to link the plugin against libmediactl the build system
>> would have to be modified.
>>
>> ================
>> Changes from v4:
>> ================
>>
>> - removed some redundant functions for traversing media device graph
>> and switched over to using existing ones
>> - avoided accessing struct v4l2_subdev from libmediactl
>> - applied various improvements
>>
>> ================
>> Changes from v3:
>> ================
>>
>> - added struct v4l2_subdev and put entity fd and
>> information about supported controls to it
>> - improved functions for negotiating and setting
>> pipeline format by using available libv4lsubdev API
>> - applied minor improvements and cleanups
>>
>> ================
>> Changes from v2:
>> ================
>>
>> - switched to using mediatext library for parsing
>> the media device configuration
>> - extended libmediactl
>> - switched to using libmediactl
>>
>> ================
>> Changes from v1:
>> ================
>>
>> - removed redundant mbus code negotiation
>> - split the parser, media device helpers and ioctl wrappers
>> to the separate modules
>> - added mechanism for querying extended controls
>> - applied various fixes and modifications
>>
>> The plugin was tested on linux-next_20150223 with patches for
>> exynos4-is that fix failing open ioctl when a sensor sub-device is not
>> linked [1] [2] [3].
>>
>> The plugin expects a configuration file:
>> /var/lib/libv4l/exynos4_capture_conf
>>
>> Exemplary configuration file:
>>
>> ==========================================
>>
>> link-conf "s5p-mipi-csis.0":1 -> "FIMC.0":0 [1]
>> ctrl-to-subdev-conf 0x0098091f -> "fimc.0.capture"
>> ctrl-to-subdev-conf 0x00980902 -> "S5C73M3"
>> ctrl-to-subdev-conf 0x00980922 -> "fimc.0.capture"
>> ctrl-to-subdev-conf 0x009a0914 -> "S5C73M3"
>>
>> ==========================================
>>
>> With this settings the plugin can be tested on the exynos4412-trats2 board
>> using following gstreamer pipeline:
>>
>> gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=960,height=720 ! fbdevsink
>>
>> Thanks,
>> Jacek Anaszewski
>>
>> [1] https://patchwork.linuxtv.org/patch/26366/
>> [2] https://patchwork.linuxtv.org/patch/26367/
>> [3] https://patchwork.linuxtv.org/patch/26368/
>>
>> Jacek Anaszewski (13):
>> mediactl: Introduce v4l2_subdev structure
>> mediactl: Add support for v4l2-ctrl-redir config
>> mediatext: Add library
>> mediactl: Add media device graph helpers
>> mediactl: Add media_device creation helpers
>> mediactl: libv4l2subdev: add VYUY8_2X8 mbus code
>> mediactl: Add support for media device pipelines
>> mediactl: libv4l2subdev: add support for comparing mbus formats
>> mediactl: libv4l2subdev: add support for setting pipeline format
>> mediactl: libv4l2subdev: add get_pipeline_entity_by_cid function
>> mediactl: Add media device ioctl API
>> mediactl: libv4l2subdev: Enable opening/closing pipelines
>> Add a libv4l plugin for Exynos4 camera
>>
>> Sakari Ailus (1):
>> mediactl: Separate entity and pad parsing
>>
>> configure.ac | 1 +
>> lib/Makefile.am | 5 +
>> lib/libv4l-exynos4-camera/Makefile.am | 7 +
>> lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 586 +++++++++++++++++++++
>> utils/media-ctl/Makefile.am | 12 +-
>> utils/media-ctl/libmediactl.c | 271 +++++++++-
>> utils/media-ctl/libmediatext.pc.in | 10 +
>> utils/media-ctl/libv4l2media_ioctl.c | 369 +++++++++++++
>> utils/media-ctl/libv4l2media_ioctl.h | 40 ++
>> utils/media-ctl/libv4l2subdev.c | 301 ++++++++++-
>> utils/media-ctl/mediactl-priv.h | 11 +-
>> utils/media-ctl/mediactl.h | 151 ++++++
>> utils/media-ctl/mediatext-test.c | 64 +++
>> utils/media-ctl/mediatext.c | 311 +++++++++++
>> utils/media-ctl/mediatext.h | 52 ++
>> utils/media-ctl/v4l2subdev.h | 131 +++++
>> 16 files changed, 2292 insertions(+), 30 deletions(-)
>> create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
>> create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
>> create mode 100644 utils/media-ctl/libmediatext.pc.in
>> create mode 100644 utils/media-ctl/libv4l2media_ioctl.c
>> create mode 100644 utils/media-ctl/libv4l2media_ioctl.h
>> create mode 100644 utils/media-ctl/mediatext-test.c
>> create mode 100644 utils/media-ctl/mediatext.c
>> create mode 100644 utils/media-ctl/mediatext.h
>>
>
>
--
Best Regards,
Jacek Anaszewski
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera
2015-06-08 9:14 ` Jacek Anaszewski
@ 2015-06-08 9:36 ` Hans Verkuil
2015-06-08 10:21 ` Jacek Anaszewski
0 siblings, 1 reply; 19+ messages in thread
From: Hans Verkuil @ 2015-06-08 9:36 UTC (permalink / raw)
To: Jacek Anaszewski
Cc: linux-media, sakari.ailus, laurent.pinchart, gjasny, hdegoede,
kyungmin.park
On 06/08/2015 11:14 AM, Jacek Anaszewski wrote:
> Hi Hans,
>
> It got stuck on this version. I have some slight improvements locally
> but haven't sent them as there hasn't been any comment to this so far.
> AFAIR Sakari had some doubts about handling multiple pipelines within
> one media controller. In this approach only one pipeline is allowed.
> There has to be a new IOCTL added for locking pipelines, to handle this
> IIRC.
Sakari, is this ioctl really needed or something that can be added later?
> Besides there are some v4l-utils build system dependency issues to
> solve, I mentioned below in the cover letter.
If I remember correctly the libmediactl API may still change, which is
why it isn't in lib. So statically linking it isn't a bad idea at the
moment. Laurent, can you confirm this?
Is there anything else that blocks this patch series?
Regards,
Hans
>
> On 06/08/2015 10:27 AM, Hans Verkuil wrote:
>> Hi Jacek,
>>
>> What is the status of this? It would be really useful to have a working plugin
>> as an example in v4l-utils.
>>
>> Regards,
>>
>> Hans
>>
>> On 02/26/2015 04:59 PM, Jacek Anaszewski wrote:
>>> This is a fifth version of the patch series adding a plugin for the
>>> Exynos4 camera.
>>>
>>> Temporarily the plugin doesn't link against libmediactl, but
>>> has its sources compiled in. Currently utils are built after
>>> the plugins, but libv4l-exynos4-camera plugin depends on the utils.
>>> In order to link the plugin against libmediactl the build system
>>> would have to be modified.
>>>
>>> ================
>>> Changes from v4:
>>> ================
>>>
>>> - removed some redundant functions for traversing media device graph
>>> and switched over to using existing ones
>>> - avoided accessing struct v4l2_subdev from libmediactl
>>> - applied various improvements
>>>
>>> ================
>>> Changes from v3:
>>> ================
>>>
>>> - added struct v4l2_subdev and put entity fd and
>>> information about supported controls to it
>>> - improved functions for negotiating and setting
>>> pipeline format by using available libv4lsubdev API
>>> - applied minor improvements and cleanups
>>>
>>> ================
>>> Changes from v2:
>>> ================
>>>
>>> - switched to using mediatext library for parsing
>>> the media device configuration
>>> - extended libmediactl
>>> - switched to using libmediactl
>>>
>>> ================
>>> Changes from v1:
>>> ================
>>>
>>> - removed redundant mbus code negotiation
>>> - split the parser, media device helpers and ioctl wrappers
>>> to the separate modules
>>> - added mechanism for querying extended controls
>>> - applied various fixes and modifications
>>>
>>> The plugin was tested on linux-next_20150223 with patches for
>>> exynos4-is that fix failing open ioctl when a sensor sub-device is not
>>> linked [1] [2] [3].
>>>
>>> The plugin expects a configuration file:
>>> /var/lib/libv4l/exynos4_capture_conf
>>>
>>> Exemplary configuration file:
>>>
>>> ==========================================
>>>
>>> link-conf "s5p-mipi-csis.0":1 -> "FIMC.0":0 [1]
>>> ctrl-to-subdev-conf 0x0098091f -> "fimc.0.capture"
>>> ctrl-to-subdev-conf 0x00980902 -> "S5C73M3"
>>> ctrl-to-subdev-conf 0x00980922 -> "fimc.0.capture"
>>> ctrl-to-subdev-conf 0x009a0914 -> "S5C73M3"
>>>
>>> ==========================================
>>>
>>> With this settings the plugin can be tested on the exynos4412-trats2 board
>>> using following gstreamer pipeline:
>>>
>>> gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,width=960,height=720 ! fbdevsink
>>>
>>> Thanks,
>>> Jacek Anaszewski
>>>
>>> [1] https://patchwork.linuxtv.org/patch/26366/
>>> [2] https://patchwork.linuxtv.org/patch/26367/
>>> [3] https://patchwork.linuxtv.org/patch/26368/
>>>
>>> Jacek Anaszewski (13):
>>> mediactl: Introduce v4l2_subdev structure
>>> mediactl: Add support for v4l2-ctrl-redir config
>>> mediatext: Add library
>>> mediactl: Add media device graph helpers
>>> mediactl: Add media_device creation helpers
>>> mediactl: libv4l2subdev: add VYUY8_2X8 mbus code
>>> mediactl: Add support for media device pipelines
>>> mediactl: libv4l2subdev: add support for comparing mbus formats
>>> mediactl: libv4l2subdev: add support for setting pipeline format
>>> mediactl: libv4l2subdev: add get_pipeline_entity_by_cid function
>>> mediactl: Add media device ioctl API
>>> mediactl: libv4l2subdev: Enable opening/closing pipelines
>>> Add a libv4l plugin for Exynos4 camera
>>>
>>> Sakari Ailus (1):
>>> mediactl: Separate entity and pad parsing
>>>
>>> configure.ac | 1 +
>>> lib/Makefile.am | 5 +
>>> lib/libv4l-exynos4-camera/Makefile.am | 7 +
>>> lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 586 +++++++++++++++++++++
>>> utils/media-ctl/Makefile.am | 12 +-
>>> utils/media-ctl/libmediactl.c | 271 +++++++++-
>>> utils/media-ctl/libmediatext.pc.in | 10 +
>>> utils/media-ctl/libv4l2media_ioctl.c | 369 +++++++++++++
>>> utils/media-ctl/libv4l2media_ioctl.h | 40 ++
>>> utils/media-ctl/libv4l2subdev.c | 301 ++++++++++-
>>> utils/media-ctl/mediactl-priv.h | 11 +-
>>> utils/media-ctl/mediactl.h | 151 ++++++
>>> utils/media-ctl/mediatext-test.c | 64 +++
>>> utils/media-ctl/mediatext.c | 311 +++++++++++
>>> utils/media-ctl/mediatext.h | 52 ++
>>> utils/media-ctl/v4l2subdev.h | 131 +++++
>>> 16 files changed, 2292 insertions(+), 30 deletions(-)
>>> create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
>>> create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
>>> create mode 100644 utils/media-ctl/libmediatext.pc.in
>>> create mode 100644 utils/media-ctl/libv4l2media_ioctl.c
>>> create mode 100644 utils/media-ctl/libv4l2media_ioctl.h
>>> create mode 100644 utils/media-ctl/mediatext-test.c
>>> create mode 100644 utils/media-ctl/mediatext.c
>>> create mode 100644 utils/media-ctl/mediatext.h
>>>
>>
>>
>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera
2015-06-08 9:36 ` Hans Verkuil
@ 2015-06-08 10:21 ` Jacek Anaszewski
0 siblings, 0 replies; 19+ messages in thread
From: Jacek Anaszewski @ 2015-06-08 10:21 UTC (permalink / raw)
To: Hans Verkuil
Cc: linux-media, sakari.ailus, laurent.pinchart, gjasny, hdegoede,
kyungmin.park
On 06/08/2015 11:36 AM, Hans Verkuil wrote:
> On 06/08/2015 11:14 AM, Jacek Anaszewski wrote:
>> Hi Hans,
>>
>> It got stuck on this version. I have some slight improvements locally
>> but haven't sent them as there hasn't been any comment to this so far.
>> AFAIR Sakari had some doubts about handling multiple pipelines within
>> one media controller. In this approach only one pipeline is allowed.
>> There has to be a new IOCTL added for locking pipelines, to handle this
>> IIRC.
>
> Sakari, is this ioctl really needed or something that can be added later?
>
>> Besides there are some v4l-utils build system dependency issues to
>> solve, I mentioned below in the cover letter.
>
> If I remember correctly the libmediactl API may still change, which is
> why it isn't in lib. So statically linking it isn't a bad idea at the
> moment. Laurent, can you confirm this?
>
> Is there anything else that blocks this patch series?
v4l-utils side issues:
I'd have to apply my local bug fixes and submit the next version.
Kernel side issues:
There is a regression in the kernel related to FIMC-LITE
and FIMC-IS-ISP entities. Effectively currently it is only possible
to setup pipelines with S5C73M3 sensor to fimc.0.capture and
fimc.1.capture entities.
I would also have to rebase the patches for exynos4-is driver
for avoiding failure on open when the device being opened
has no connected sensor.
--
Best Regards,
Jacek Anaszewski
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2015-06-08 10:21 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-26 15:59 [v4l-utils PATCH/RFC v5 00/14] Add a plugin for Exynos4 camera Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 01/14] mediactl: Introduce v4l2_subdev structure Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 02/14] mediactl: Add support for v4l2-ctrl-redir config Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 03/14] mediactl: Separate entity and pad parsing Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 04/14] mediatext: Add library Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 05/14] mediactl: Add media device graph helpers Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 06/14] mediactl: Add media_device creation helpers Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 07/14] mediactl: libv4l2subdev: add VYUY8_2X8 mbus code Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 08/14] mediactl: Add support for media device pipelines Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 09/14] mediactl: libv4l2subdev: add support for comparing mbus formats Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 10/14] mediactl: libv4l2subdev: add support for setting pipeline format Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 11/14] mediactl: libv4l2subdev: add get_pipeline_entity_by_cid function Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 12/14] mediactl: Add media device ioctl API Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 13/14] mediactl: libv4l2subdev: Enable opening/closing pipelines Jacek Anaszewski
2015-02-26 15:59 ` [v4l-utils PATCH/RFC v5 14/14] Add a libv4l plugin for Exynos4 camera Jacek Anaszewski
2015-06-08 8:27 ` [v4l-utils PATCH/RFC v5 00/14] Add a " Hans Verkuil
2015-06-08 9:14 ` Jacek Anaszewski
2015-06-08 9:36 ` Hans Verkuil
2015-06-08 10:21 ` Jacek Anaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).