Skip to contentSkip to conversation

Libv4l: Add a plugin for the Exynos4 camera

PATCH Superseded Jacek Anaszewski 3 participants 11 messages Oct 17, 2014 – Oct 22, 2014

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Libv4l: Add a plugin for the Exynos4 camera

This is a second version of the patch series adding a plugin for the Exynos4 camera.

================
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 latest media-tree.git master with patches for exynos4-is that fix failing open 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 {
        source_entity: s5p-mipi-csis.0
        source_pad: 1
        sink_entity: FIMC.0
        sink_pad: 0
}

v4l2-controls {
Color Effects: fimc.0.capture
Saturation: S5C73M3
Image Stabilization: S5C73M3
White Balance, Auto & Preset: S5C73M3
Exposure, Metering Mode: 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

In order to avoid fbdevsink element failure the fix [4] for exynos-drm driver is required.

Thanks,
Jacek Anaszewski

[1] https://patchwork.linuxtv.org/patch/26366/
[2] https://patchwork.linuxtv.org/patch/26367/
[3] https://patchwork.linuxtv.org/patch/26368/
[4] http://www.spinics.net/lists/dri-devel/msg66494.html

Jacek Anaszewski (4):
Add a media device configuration file parser. Add media device related data structures and API. Add wrappers for media device related ioctl calls. Add a libv4l plugin for Exynos4 camera

 configure.ac                                      |    1 +
 lib/Makefile.am                                   |    5 +-
 lib/include/libv4l2-mdev-ioctl.h                  |   45 +
 lib/include/libv4l2-mdev.h                        |  195 +++++
 lib/include/libv4l2-media-conf-parser.h           |  148 ++++
 lib/libv4l-exynos4-camera/Makefile.am             |    8 +
 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c |  569 ++++++++++++
 lib/libv4l2/Makefile.am                           |    5 +-
 lib/libv4l2/libv4l2-mdev-ioctl.c                  |  329 +++++++
 lib/libv4l2/libv4l2-mdev.c                        |  975 +++++++++++++++++++++
 lib/libv4l2/libv4l2-media-conf-parser.c           |  441 ++++++++++
 11 files changed, 2718 insertions(+), 3 deletions(-)
 create mode 100644 lib/include/libv4l2-mdev-ioctl.h
 create mode 100644 lib/include/libv4l2-mdev.h
 create mode 100644 lib/include/libv4l2-media-conf-parser.h
 create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
 create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
 create mode 100644 lib/libv4l2/libv4l2-mdev-ioctl.c
 create mode 100644 lib/libv4l2/libv4l2-mdev.c
 create mode 100644 lib/libv4l2/libv4l2-media-conf-parser.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/4 Add a media device configuration file parser.

This patch adds a parser for a media device configuration file. The parser expects the configuration file containing links end v4l2-controls definitions as described in the header file being added. The links describe connections between media entities and v4l2-controls define the target sub-devices for particular user controls related ioctl calls.

---
 lib/include/libv4l2-media-conf-parser.h |  148 +++++++++++
 lib/libv4l2/libv4l2-media-conf-parser.c |  441 +++++++++++++++++++++++++++++++
 2 files changed, 589 insertions(+)
 create mode 100644 lib/include/libv4l2-media-conf-parser.h
 create mode 100644 lib/libv4l2/libv4l2-media-conf-parser.c
lib/include/libv4l2-media-conf-parser.h new file +148 -0
new file mode 100644
index 0000000..b2dba3a
@@ -0,0 +1,148 @@
+/*
+ * Parser of media device configuration file.
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *              http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski <[email protected]>
+ *
+ * The configuration file has to comply with following format:
+ *
+ * Link description entry format:
+ *
+ * link {
+ * <TAB>source_entity: <entity_name><LF>
+ * <TAB>source_pad: <pad_id><LF>
+ * <TAB>sink_entity: <entity_name><LF>
+ * <TAB>sink_pad: <pad_id><LF>
+ * }
+ *
+ * The V4L2 control group format:
+ *
+ * v4l2-controls {
+ * <TAB><control1_name>: <entity_name><LF>
+ * <TAB><control2_name>: <entity_name><LF>
+ * ...
+ * <TAB><controlN_name>: <entity_name><LF>
+ * }
+ *
+ * Example:
+ *
+ * link {
+ *         source_entity: s5p-mipi-csis.0
+ *         source_pad: 1
+ *         sink_entity: FIMC.0
+ *         sink_pad: 0
+ * }
+ *
+ * v4l2-controls {
+ *         Color Effects: S5C73M3
+ *         Saturation: S5C73M3
+ * }
+ *
+ *
+ * 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 __LIBV4L_MEDIA_CONF_PARSER_H
+#define __LIBV4L_MEDIA_CONF_PARSER_H
+
+#include <libv4l2.h>
+
+#ifdef DEBUG
+#define V4L2_MDCFG_PARSER_DBG(format, ARG...)\
+	printf("[%s:%d] [%s] " format " \n", __FILE__, __LINE__, __func__, ##ARG)
+#else
+#define V4L2_MDCFG_PARSER_DBG(format, ARG...)
+#endif
+
+#define V4L2_MDCFG_PARSER_ERR(format, ARG...)\
+	fprintf(stderr, "Libv4l device config parser: "format "\n", ##ARG)
+
+#define V4L2_MDCFG_PARSER_LOG(format, ARG...)\
+	fprintf(stdout, "Libv4l device config parser: "format "\n", ##ARG)
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+/*
+ * struct libv4l2_media_link_conf - media entity link configuration
+ * @source_entity:	source entity of the link
+ * @source_pad:		source pad id
+ * @sink_entity:	sink entity of the link
+ * @sink_pad:		sink pad id
+ * @next:		pointer to the next data structure in the list
+ */
+struct libv4l2_media_link_conf {
+	char *source_entity;
+	int source_pad;
+	char *sink_entity;
+	int sink_pad;
+	struct libv4l2_media_link_conf *next;
+};
+
+/*
+ * struct libv4l2_media_ctrl_conf - user control to media entity configuration
+ * @control_name:	user control name
+ * @entity_name:	media entity name
+ * @entity:		media entity matched by entity_name
+ * @cid:		user control id
+ * @next:		pointer to the next data structure in the list
+ */
+struct libv4l2_media_ctrl_conf {
+	char *control_name;
+	char *entity_name;
+	struct media_entity *entity;
+	int cid;
+	struct libv4l2_media_ctrl_conf *next;
+};
+
+/*
+ * struct libv4l2_media_device_conf - media device config
+ * @links:	media entity link config
+ * @controls:	user control to media entity config
+ */
+struct libv4l2_media_device_conf {
+	struct libv4l2_media_link_conf *links;
+	struct libv4l2_media_ctrl_conf *controls;
+};
+
+/*
+ * struct libv4l2_conf_parser_ctx - parser context
+ * @line_start_pos:	start position of the current line in the file buffer
+ * @line_end:		end position of the current line in the file buffer
+ * @buf_pos:		file buffer position of the currently analyzed character
+ * @buf:		config file buffer
+ * @buf_size:		number of characters in the file buffer
+ */
+struct libv4l2_conf_parser_ctx {
+	int line_start_pos;
+	int line_end_pos;
+	int buf_pos;
+	char *buf;
+	int buf_size;
+};
+
+/*
+ * Read configuration file and initialize config argument with the parsed data.
+ * The config's links and controls fields must be released with use of
+ * libv4l2_media_conf_release_links and libv4l2_media_conf_release_controls
+ * functions respectively.
+ */
+int libv4l2_media_conf_read(char *fname,
+			struct libv4l2_media_device_conf *config);
+
+/* Release links configuration */
+void libv4l2_media_conf_release_links(struct libv4l2_media_link_conf *cfg);
+
+/* Release controls configuration */
+void libv4l2_media_conf_release_controls(struct libv4l2_media_ctrl_conf *cfg);
+
+#endif /* __LIBV4L_MEDIA_CONF_PARSER_H */
lib/libv4l2/libv4l2-media-conf-parser.c new file +441 -0

441 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH/RFC v2 1/4] Add a media device configuration file parser.

Hi Jacek,

Quoted 32 lines · Jacek Anaszewski

This patch adds a parser for a media device configuration file. The parser expects the configuration file containing links end v4l2-controls definitions as described in the header file being added. The links describe connections between media entities and v4l2-controls define the target sub-devices for particular user controls related ioctl calls.

---
 lib/include/libv4l2-media-conf-parser.h |  148 +++++++++++
 lib/libv4l2/libv4l2-media-conf-parser.c |  441 +++++++++++++++++++++++++++++++
 2 files changed, 589 insertions(+)
 create mode 100644 lib/include/libv4l2-media-conf-parser.h
 create mode 100644 lib/libv4l2/libv4l2-media-conf-parser.c
lib/include/libv4l2-media-conf-parser.h new file +8 -0
new file mode 100644
index 0000000..b2dba3a
@@ -0,0 +1,148 @@
+/*
+ * Parser of media device configuration file.
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *              http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski <[email protected]>
+ *

lib/include/libv4l2-media-conf-parser.h line 18

Quoted 10 lines
lib/include/libv4l2-media-conf-parser.h new file +10 -0
+ * The configuration file has to comply with following format:
+ *
+ * Link description entry format:
+ *
+ * link {
+ * <TAB>source_entity: <entity_name><LF>
+ * <TAB>source_pad: <pad_id><LF>
+ * <TAB>sink_entity: <entity_name><LF>
+ * <TAB>sink_pad: <pad_id><LF>
+ * }

Could you use the existing libmediactl format? The parser exists as well.

As a matter of fact, I have a few patches to make it easier to user in a library.

libmediactl appears to be located under utils/media-ctl. Perhaps it's be better placed under lib. Cc Laurent.

lib/include/libv4l2-media-conf-parser.h line 27

Quoted 8 lines
lib/include/libv4l2-media-conf-parser.h new file +8 -0
+ * The V4L2 control group format:
+ *
+ * v4l2-controls {
+ * <TAB><control1_name>: <entity_name><LF>
+ * <TAB><control2_name>: <entity_name><LF>
+ * ...
+ * <TAB><controlN_name>: <entity_name><LF>
+ * }

I didn't know you were working on this.

I have a small library which does essentially the same. The implementation is incomplete, that's why I hadn't posted it to the list. We could perhaps discuss this a little bit tomorrow. When would you be available, in case you are?

What would you think of using a little bit more condensed format for this, similar to that of libmediactl?

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
#3 lore raw

Re: [PATCH/RFC v2 1/4] Add a media device configuration file parser.

Hi Sakari,

Quoted 39 lines · Sakari Ailus

Hi Jacek,

Quoted 36 lines · Jacek Anaszewski

This patch adds a parser for a media device configuration file. The parser expects the configuration file containing links end v4l2-controls definitions as described in the header file being added. The links describe connections between media entities and v4l2-controls define the target sub-devices for particular user controls related ioctl calls.

---
  lib/include/libv4l2-media-conf-parser.h |  148 +++++++++++
  lib/libv4l2/libv4l2-media-conf-parser.c |  441 +++++++++++++++++++++++++++++++
  2 files changed, 589 insertions(+)

create mode 100644 lib/include/libv4l2-media-conf-parser.h create mode 100644 lib/libv4l2/libv4l2-media-conf-parser.c

lib/include/libv4l2-media-conf-parser.h new file +12 -0
new file mode 100644
index 0000000..b2dba3a
@@ -0,0 +1,148 @@
+/*
+ * Parser of media device configuration file.
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *              http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski <[email protected]>
+ *
+ * The configuration file has to comply with following format:
+ *
+ * Link description entry format:
+ *
Quoted 8 lines

lib/include/libv4l2-media-conf-parser.h line 18

Quoted 6 lines
lib/include/libv4l2-media-conf-parser.h new file +6 -0
+ * link {
+ * <TAB>source_entity: <entity_name><LF>
+ * <TAB>source_pad: <pad_id><LF>
+ * <TAB>sink_entity: <entity_name><LF>
+ * <TAB>sink_pad: <pad_id><LF>
+ * }

Could you use the existing libmediactl format? The parser exists as well.

Of course, I will switch to using it.

Quoted 15 lines

As a matter of fact, I have a few patches to make it easier to user in a library.

libmediactl appears to be located under utils/media-ctl. Perhaps it's be better placed under lib. Cc Laurent.

lib/include/libv4l2-media-conf-parser.h line 27

Quoted 8 lines
lib/include/libv4l2-media-conf-parser.h new file +8 -0
+ * The V4L2 control group format:
+ *
+ * v4l2-controls {
+ * <TAB><control1_name>: <entity_name><LF>
+ * <TAB><control2_name>: <entity_name><LF>
+ * ...
+ * <TAB><controlN_name>: <entity_name><LF>
+ * }
Quoted 1 line

I didn't know you were working on this.

Actually I did the main part of work around 1,5 year ago as a part of familiarizing myself with V4L2 media controller API.

Quoted 5 lines

I have a small library which does essentially the same. The implementation is incomplete, that's why I hadn't posted it to the list. We could perhaps discuss this a little bit tomorrow. When would you be available, in case you are?

I will be available around 8 hours from now on.

Quoted 3 lines

What would you think of using a little bit more condensed format for this, similar to that of libmediactl?

Could you spot a place where the format is defined?

Best Regards,
Jacek Anaszewski

#4 lore raw

Re: [PATCH/RFC v2 1/4] Add a media device configuration file parser.

Hi Jacek,

On Tue, Oct 21, 2014 at 09:17:00AM +0200, Jacek Anaszewski wrote:
...

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

+ * The V4L2 control group format:
+ *
+ * v4l2-controls {
+ * <TAB><control1_name>: <entity_name><LF>
+ * <TAB><control2_name>: <entity_name><LF>
+ * ...
+ * <TAB><controlN_name>: <entity_name><LF>
+ * }

Quoted 4 lines
Quoted 1 line

I didn't know you were working on this.

Actually I did the main part of work around 1,5 year ago as a part of familiarizing myself with V4L2 media controller API.

:-D

I think it's about time we get things like this to libv4l.

Quoted 7 lines
Quoted 5 lines

I have a small library which does essentially the same. The implementation is incomplete, that's why I hadn't posted it to the list. We could perhaps discuss this a little bit tomorrow. When would you be available, in case you are?

I will be available around 8 hours from now on.

I couldn't see you on #v4l, would an hour from now (13:30 Finnish time) be ok for you?

Quoted 5 lines
Quoted 3 lines

What would you think of using a little bit more condensed format for this, similar to that of libmediactl?

Could you spot a place where the format is defined?

At the moment there's none, but I thought of a similar format used by libmediactl.

Signature · 4 lines
Cheers,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
#5 lore raw

Re: [PATCH/RFC v2 1/4] Add a media device configuration file parser.

Hi Sakari,

Quoted 13 lines · Sakari Ailus

Hi Jacek,

On Tue, Oct 21, 2014 at 09:17:00AM +0200, Jacek Anaszewski wrote:
...

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines

+ * The V4L2 control group format:
+ *
+ * v4l2-controls {
+ * <TAB><control1_name>: <entity_name><LF>
+ * <TAB><control2_name>: <entity_name><LF>
+ * ...
+ * <TAB><controlN_name>: <entity_name><LF>
+ * }

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I didn't know you were working on this.

Actually I did the main part of work around 1,5 year ago as a part of familiarizing myself with V4L2 media controller API.

:-D

I think it's about time we get things like this to libv4l.

Definitely :)

Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

I have a small library which does essentially the same. The implementation is incomplete, that's why I hadn't posted it to the list. We could perhaps discuss this a little bit tomorrow. When would you be available, in case you are?

I will be available around 8 hours from now on.

I couldn't see you on #v4l, would an hour from now (13:30 Finnish time) be ok for you?

What about 14:00 Finnish time?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

What would you think of using a little bit more condensed format for this, similar to that of libmediactl?

Could you spot a place where the format is defined?

At the moment there's none, but I thought of a similar format used by libmediactl.

OK, to be discussed.

Best Regards,
Jacek Anaszewski

#6 lore raw

PATCH v2 2/4 Add media device related data structures and API.

In reply to Jacek Anaszewski

Add helpers for retrieving media device topology and manipulating its configuration.

---
 lib/include/libv4l2-mdev.h |  195 +++++++++
 lib/libv4l2/libv4l2-mdev.c |  975 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 1170 insertions(+)
 create mode 100644 lib/include/libv4l2-mdev.h
 create mode 100644 lib/libv4l2/libv4l2-mdev.c
lib/include/libv4l2-mdev.h new file +195 -0
new file mode 100644
index 0000000..cb28835
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *              http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski <[email protected]>
+ *
+ * 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 __LIBV4L2_MDEV_H
+#define __LIBV4L2_MDEV_H
+
+#include <libv4l2-media-conf-parser.h>
+#include <linux/v4l2-subdev.h>
+#include <linux/videodev2.h>
+#include <sys/syscall.h>
+
+#define SYS_IOCTL(fd, cmd, arg) \
+	syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg))
+
+#ifdef DEBUG
+#define V4L2_MDEV_DBG(format, ARG...)\
+        printf("[%s:%d] [%s] " format " \n", __FILE__, __LINE__, __func__, ##ARG)
+#else
+#define V4L2_MDEV_DBG(format, ARG...)
+#endif
+
+#define V4L2_MDEV_ERR(format, ARG...)\
+        fprintf(stderr, "Libv4l media device: "format "\n", ##ARG)
+
+#define V4L2_MDEV_LOG(format, ARG...)\
+        fprintf(stdout, "Libv4l media device: "format "\n", ##ARG)
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+/*
+ * struct media_entity - media device entity data
+ * @id:			media entity id within media controller
+ * @name:		media entity name
+ * @node_name:		media entity related device node name
+ * @pads:		array of media_entity pads
+ * @num_pads:		number of elements in the pads array
+ * @links:		array of media_entity links
+ * @num_links:		number of elements in the links array
+ * @subdev_fmt:		related sub-device format
+ * @fd:			related sub-device node file descriptor
+ * @src_pad_id:		source pad id when entity is linked
+ * @sink_pad_id:	sink pad id when entity is linked
+ * @next:		pointer to the next data structure in the list
+ */
+struct media_entity {
+	int id;
+	char name[32];
+	char node_name[32];
+	struct media_pad_desc *pads;
+	int num_pads;
+	struct media_link_desc *links;
+	int num_links;
+	struct v4l2_subdev_format subdev_fmt;
+	int fd;
+	int src_pad_id;
+	int sink_pad_id;
+	struct media_entity *next;
+};
+
+/*
+ * struct media_device - media device comprising the opened video device
+ * @entities:		media entities comprised by a video device
+ * @num_entities:	number of media entities within a video device
+ * @pipeline:		pipeline of media entities from sensor to the video node
+ * @media_fd:		file descriptor of the media device this
+ *			video device belongs to
+ * @config:		media device configuration
+ * @vid_fd:		file descriptor of the opened video device node
+ */
+struct media_device {
+	struct media_entity *entities;
+	int num_entities;
+	struct media_entity *pipeline;
+	int media_fd;
+	struct libv4l2_media_device_conf config;
+	int vid_fd;
+};
+
+int mdev_get_node_by_devnum(unsigned int major, unsigned int minor,
+			char *node_name);
+
+int mdev_get_node_by_fd(int fd, char *node_name);
+
+int mdev_enumerate_links(struct media_device *mdev);
+
+int mdev_release_entities(struct media_device *mdev);
+
+int mdev_get_device_topology(struct media_device *mdev);
+
+int mdev_has_device_node(struct media_device *mdev, char *entity_node,
+			char **entity_name);
+
+int mdev_get_media_node(struct media_device *mdev, int capture_fd,
+			char **entity_name);
+
+int mdev_get_pad_parent_name(struct media_device *mdev,
+			struct media_pad_desc *pad, char **parent_name);
+
+int mdev_entity_get_id_by_name(struct media_device *mdev, char *name, int *id);
+
+int mdev_has_link_pad(struct media_link_desc *link,
+			struct media_pad_desc *pad);
+
+int mdev_pad_busy(struct media_device *mdev, struct media_pad_desc *pad,
+			struct media_link_desc **link);
+
+int mdev_print_link_log(char *message, struct media_device *mdev,
+			struct media_link_desc *link);
+
+int mdev_disable_link(struct media_device *mdev,
+			struct media_link_desc *link);
+
+int mdev_get_v4l2_pad(struct media_device *mdev, char *entity_name,
+			int pad_id, struct media_pad_desc *pad);
+
+int mdev_same_link(struct media_link_desc *link1,
+			struct media_link_desc *link2);
+
+int mdev_link_enabled(struct media_device *mdev,
+			struct media_link_desc *link);
+
+int mdev_get_entity_by_pad(struct media_device *mdev,
+			struct media_pad_desc *pad,
+			struct media_entity **entity);
+
+int mdev_setup_config_links(struct media_device *mdev,
+			struct libv4l2_media_link_conf *links);
+
+struct media_entity *mdev_get_entity_by_name(struct media_device *mdev,
+			char *name);
+
+struct media_entity *mdev_conf_get_entity_by_cid(
+			struct libv4l2_media_ctrl_conf *ctrl_cfg,
+			int cid);
+
+int mdev_is_control_supported(struct media_device *mdev,
+			struct libv4l2_media_ctrl_conf *ctrl_cfg);
+
+int mdev_validate_control_config(struct media_device *mdev,
+			struct libv4l2_media_ctrl_conf *ctrl_cfg);
+
+int mdev_get_entity_by_fd(struct media_device *mdev, int fd,
+			struct media_entity **entity);
+
+int mdev_get_pads_by_entity(struct media_entity *entity,
+			struct media_pad_desc **pads,
+			int *num_pads, unsigned int type);
+
+int mdev_get_src_entity_by_link(struct media_device *mdev,
+			struct media_link_desc *link,
+			struct media_entity **entity);
+
+int mdev_get_link_by_sink_pad(struct media_device *mdev,
+			struct media_pad_desc *pad,
+			struct media_link_desc **link);
+
+int mdev_get_link_by_source_pad(struct media_entity *entity,
+			struct media_pad_desc *pad,
+			struct media_link_desc **link);
+
+int mdev_get_busy_pads_by_entity(struct media_device *mdev,
+			struct media_entity *entity,
+			struct media_pad_desc **busy_pads,
+			int *num_busy_pads,
+			unsigned int type);
+
+int mdev_get_pad_by_index(struct media_pad_desc *pads, int num_pads,
+			int index, struct media_pad_desc *out_pad);
+
+int mdev_discover_pipeline_by_fd(struct media_device *mdev, int fd);
+
+void mdev_close_pipeline_subdevs(struct media_entity *pipeline);
+
+int mdev_open_pipeline_subdevs(struct media_entity *pipeline);
+
+int mdev_verify_format(struct v4l2_mbus_framefmt *fmt1,
+			struct v4l2_mbus_framefmt *fmt2);
+
+int mdev_has_pipeline_entity(struct media_entity *pipeline, char *entity);
+
+#endif /* __LIBV4L2_MDEV_H */
lib/libv4l2/libv4l2-mdev.c new file +975 -0

975 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#7 lore raw

Re: [PATCH/RFC v2 2/4] Add media device related data structures and API.

Hi Jacek,

On Fri, Oct 17, 2014 at 04:54:40PM +0200, Jacek Anaszewski wrote:
...

Quoted 19 lines
lib/include/libv4l2-mdev.h new file +19 -0
+/*
+ * struct media_entity - media device entity data
+ * @id:			media entity id within media controller
+ * @name:		media entity name
+ * @node_name:		media entity related device node name
+ * @pads:		array of media_entity pads
+ * @num_pads:		number of elements in the pads array
+ * @links:		array of media_entity links
+ * @num_links:		number of elements in the links array
+ * @subdev_fmt:		related sub-device format
+ * @fd:			related sub-device node file descriptor
+ * @src_pad_id:		source pad id when entity is linked
+ * @sink_pad_id:	sink pad id when entity is linked
+ * @next:		pointer to the next data structure in the list
+ */
+struct media_entity {
+	int id;
+	char name[32];
+	char node_name[32];

lib/include/libv4l2-mdev.h line 72

Quoted 10 lines
lib/include/libv4l2-mdev.h new file +10 -0
+	struct media_pad_desc *pads;
+	int num_pads;
+	struct media_link_desc *links;
+	int num_links;
+	struct v4l2_subdev_format subdev_fmt;
+	int fd;
+	int src_pad_id;
+	int sink_pad_id;
+	struct media_entity *next;
+};

Could you use libmediactl and libv4l2subdev instead here as well? They do actually implement much of what you do here. Feel free to comment on the API. The libraries have a little bit different background than this one. Obviously there's functionality in this library what's not in the two; some of this might belong to either of the two libraries.

I think we'll need V4L2 sub-device related information stored next to the media entities as well, so that's something to be added.

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
#8 lore raw

Re: [PATCH/RFC v2 2/4] Add media device related data structures and API.

Hi Sakari,

Quoted 39 lines · On Wednesday 22 October 2014 13:03:02 Sakari Ailus wrote:

On Fri, Oct 17, 2014 at 04:54:40PM +0200, Jacek Anaszewski wrote:
...

Quoted 19 lines
lib/include/libv4l2-mdev.h new file +19 -0
+/*
+ * struct media_entity - media device entity data
+ * @id:			media entity id within media controller
+ * @name:		media entity name
+ * @node_name:		media entity related device node name
+ * @pads:		array of media_entity pads
+ * @num_pads:		number of elements in the pads array
+ * @links:		array of media_entity links
+ * @num_links:		number of elements in the links array
+ * @subdev_fmt:		related sub-device format
+ * @fd:			related sub-device node file descriptor
+ * @src_pad_id:		source pad id when entity is linked
+ * @sink_pad_id:	sink pad id when entity is linked
+ * @next:		pointer to the next data structure in the list
+ */
+struct media_entity {
+	int id;
+	char name[32];
+	char node_name[32];

lib/include/libv4l2-mdev.h line 72

Quoted 10 lines
lib/include/libv4l2-mdev.h new file +10 -0
+	struct media_pad_desc *pads;
+	int num_pads;
+	struct media_link_desc *links;
+	int num_links;
+	struct v4l2_subdev_format subdev_fmt;
+	int fd;
+	int src_pad_id;
+	int sink_pad_id;
+	struct media_entity *next;
+};

Could you use libmediactl and libv4l2subdev instead here as well? They do actually implement much of what you do here. Feel free to comment on the API. The libraries have a little bit different background than this one. Obviously there's functionality in this library what's not in the two; some of this might belong to either of the two libraries.

Quoted 2 lines

I think we'll need V4L2 sub-device related information stored next to the media entities as well, so that's something to be added.

I generic mechanism to attach subsystem-specific data to entities sounds good to me. The fd field could then be moved out of struct media_entity.

Signature · 3 lines
Regards,

Laurent Pinchart
#9 lore raw

PATCH v2 3/4 Add wrappers for media device related ioctl calls.

In reply to Jacek Anaszewski

Some ioctl calls predestined for a media device have to be separately executed on each sub-device of a pipeline or redirected to the predefined one basing on the configuration data. This patch adds wrappers that adjust intercepted ioctl calls and execute them on every required sub-device.

---
 lib/include/libv4l2-mdev-ioctl.h |   45 ++++++
 lib/libv4l2/libv4l2-mdev-ioctl.c |  329 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 374 insertions(+)
 create mode 100644 lib/include/libv4l2-mdev-ioctl.h
 create mode 100644 lib/libv4l2/libv4l2-mdev-ioctl.c
lib/include/libv4l2-mdev-ioctl.h new file +45 -0
new file mode 100644
index 0000000..10326be
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *              http://www.samsung.com
+ *
+ * Author: Jacek Anaszewski <[email protected]>
+ *
+ * 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 __LIBV4L2_MDEV_IOCTL_H
+#define __LIBV4L2_MDEV_IOCTL_H
+
+#include <linux/videodev2.h>
+#include <libv4l2-mdev.h>
+
+int mdev_ioctl_set_fmt(struct media_device *mdev,
+			struct v4l2_format *fmt);
+
+int mdev_ioctl_ctrl(struct media_device *mdev, int request,
+			struct v4l2_control *arg);
+
+int mdev_ioctl_ext_ctrl(struct media_device *mdev, int request,
+			struct v4l2_ext_controls *arg);
+
+int mdev_ioctl_single_ext_ctrl(struct media_device *mdev,
+			int request, struct v4l2_ext_controls *arg);
+
+int mdev_ioctl_queryctrl(struct media_device *mdev,
+			struct v4l2_queryctrl *arg);
+
+int mdev_ioctl_query_ext_ctrl(struct media_device *mdev,
+			struct v4l2_query_ext_ctrl *arg);
+
+int mdev_ioctl_querymenu(struct media_device *mdev,
+			struct v4l2_querymenu *arg);
+
+#endif /* __LIBV4L2_MDEV_IOCTL_H */
lib/libv4l2/libv4l2-mdev-ioctl.c new file +329 -0

329 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#10 lore raw

PATCH v2 4/4 Add a libv4l plugin for Exynos4 camera

In reply to 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.

---
 configure.ac                                      |    1 +
 lib/Makefile.am                                   |    5 +-
 lib/libv4l-exynos4-camera/Makefile.am             |    8 +
 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c |  569 +++++++++++++++++++++
 lib/libv4l2/Makefile.am                           |    5 +-
 5 files changed, 585 insertions(+), 3 deletions(-)
 create mode 100644 lib/libv4l-exynos4-camera/Makefile.am
 create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c
configure.ac +1 -0
index c9b0524..ae653b9 100644
@@ -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
lib/Makefile.am +3 -2
index 3a0e19c..29455ab 100644
@@ -3,9 +3,10 @@ SUBDIRS = \
 	libv4l2 \
 	libv4l1 \
 	libv4l2rds \
-	libv4l-mplane
+	libv4l-mplane \
+	libv4l-exynos4-camera
 
 if LINUX_OS
 SUBDIRS += \
 	libdvbv5
-endif
\ No newline at end of file
+endif
lib/libv4l-exynos4-camera/Makefile.am new file +8 -0
new file mode 100644
index 0000000..a83c3f2
@@ -0,0 +1,8 @@
+if WITH_V4L_PLUGINS
+libv4l2plugin_LTLIBRARIES = libv4l-exynos4-camera.la
+endif
+
+libv4l_exynos4_camera_la_SOURCES = libv4l-exynos4-camera.c
+libv4l_exynos4_camera_la_CPPFLAGS = -fvisibility=hidden -std=gnu99
+libv4l_exynos4_camera_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -lpthread
+libv4l_exynos4_camera_la_LIBADD = ../libv4l2/libv4l2-mdev.la
lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c new file +569 -0

569 lines not on this page · raw message

lib/libv4l2/Makefile.am +4 -1
index c60f89b..868135a 100644
@@ -2,6 +2,7 @@ if WITH_LIBV4L
 lib_LTLIBRARIES = libv4l2.la
 include_HEADERS = ../include/libv4l2.h ../include/libv4l-plugin.h
 pkgconfig_DATA = libv4l2.pc
+noinst_LTLIBRARIES = libv4l2-mdev.la
 LIBV4L2_VERSION = -version-info 0
 if WITH_V4L_WRAPPERS
 libv4l2priv_LTLIBRARIES = v4l2convert.la
@@ -12,7 +13,7 @@ install-exec-hook:
 
 endif
 else
-noinst_LTLIBRARIES = libv4l2.la
+noinst_LTLIBRARIES = libv4l2.la libv4l2-mdev.la
 endif
 
 libv4l2_la_SOURCES = libv4l2.c v4l2-plugin.c log.c libv4l2-priv.h
@@ -24,3 +25,5 @@ v4l2convert_la_SOURCES = v4l2convert.c
 v4l2convert_la_LIBADD = libv4l2.la
 v4l2convert_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
 v4l2convert_la_LIBTOOLFLAGS = --tag=disable-static
+
+libv4l2_mdev_la_SOURCES = libv4l2-mdev.c libv4l2-media-conf-parser.c ../include/libv4l2-mdev.h ../include/libv4l-media-conf-parser.h libv4l2-mdev-ioctl.c ../include/libv4l2-mdev-ioctl.h
Signature · 1 line
1.7.9.5