All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-media@vger.kernel.org, m.chehab@samsung.com,
	gjasny@googlemail.com, hdegoede@redhat.com,
	hans.verkuil@cisco.com, b.zolnierkie@samsung.com,
	kyungmin.park@samsung.com, sakari.ailus@linux.intel.com,
	laurent.pinchart@ideasonboard.com
Subject: Re: [PATCH/RFC v4 11/11] Add a libv4l plugin for Exynos4 camera
Date: Fri, 27 Feb 2015 10:32:39 +0100	[thread overview]
Message-ID: <54F039B7.5020800@samsung.com> (raw)
In-Reply-To: <20141127084129.GM8907@valkosipuli.retiisi.org.uk>

Hi Sakari,

On 11/27/2014 09:41 AM, Sakari Ailus wrote:
> Hi Jacek,
>
> On Fri, Nov 21, 2014 at 05:14:40PM +0100, Jacek Anaszewski wrote:
>> 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.
>>
[...]
>> +
>> +static void *plugin_init(int fd)
>> +{
>> +	struct v4l2_capability cap;
>> +	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));
>
> Could you use the fd directly instead of translating that to the device
> node? fstat(2) gives you directly inode / device major + minor which you can
> then use to find the MC device.

After trying to switch it as you requested I decided to stay by current
implementation to avoid the need for translating fd to device node
twice.

If we changed:

media_device_new_by_entity_devname -> media_device_new_by_entity_fd

then media_device_new_by_entity_fd would have to call fstat to find
out the entity node name. Nonetheless we would have to call fstat
one more time to obtain sink_entity to be passed below to
media_entity_get_name.

Therefore, it is better to obtain devname once and use it for
both creating media_device and obtaining sink_entity node name.


>> +	if (sink_entity == NULL) {
>> +		V4L2_EXYNOS4_ERR("Failed to get sinkd entity name.");
>> +		goto err_get_sink_entity;
>> +	}
>> +
>> +	/* The last entity in the pipeline represents video device node */
>> +	media_entity_set_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;
>> +	}

-- 
Best Regards,
Jacek Anaszewski

  parent reply	other threads:[~2015-02-27  9:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-21 16:14 [PATCH/RFC v4 00/11] Add a plugin for Exynos4 camera Jacek Anaszewski
2014-11-21 16:14 ` [PATCH/RFC v4 01/11] mediactl: Introduce v4l2_subdev structure Jacek Anaszewski
2014-11-25 11:36   ` Sakari Ailus
2014-11-25 12:22     ` Jacek Anaszewski
2014-11-26 10:20       ` Sakari Ailus
2014-11-21 16:14 ` [PATCH/RFC v4 02/11] mediactl: Add support for v4l2 controls Jacek Anaszewski
2014-11-21 16:14 ` [PATCH/RFC v4 03/11] mediactl: Separate entity and pad parsing Jacek Anaszewski
2014-11-21 16:14 ` [PATCH/RFC v4 04/11] mediatext: Add library Jacek Anaszewski
2014-11-21 16:14 ` [PATCH/RFC v4 05/11] mediactl: Add media device graph helpers Jacek Anaszewski
2014-11-28 17:06   ` Sakari Ailus
2014-12-01 11:23     ` Jacek Anaszewski
2014-12-01 12:30       ` Sakari Ailus
2014-12-01 14:21         ` Jacek Anaszewski
2014-11-21 16:14 ` [PATCH/RFC v4 06/11] mediactl: Add media_device creation helpers Jacek Anaszewski
2014-11-21 16:14 ` [PATCH/RFC v4 07/11] media-ctl: libv4l2subdev: add VYUY8_2X8 mbus code Jacek Anaszewski
2014-11-28 17:10   ` Sakari Ailus
2014-11-21 16:14 ` [PATCH/RFC v4 08/11] mediactl: Add support for media device pipelines Jacek Anaszewski
2014-11-21 16:14 ` [PATCH/RFC v4 09/11] mediactl: Close only pipeline sub-devices Jacek Anaszewski
2014-11-21 16:14 ` [PATCH/RFC v4 10/11] mediactl: Add media device ioctl API Jacek Anaszewski
2014-11-21 16:14 ` [PATCH/RFC v4 11/11] Add a libv4l plugin for Exynos4 camera Jacek Anaszewski
2014-11-27  8:41   ` Sakari Ailus
2014-11-28 13:29     ` Jacek Anaszewski
2015-02-27  9:32     ` Jacek Anaszewski [this message]
2015-03-15 19:07   ` Gregor Jasny
2015-03-16  8:54     ` Jacek Anaszewski
2015-03-15 19:12   ` Gregor Jasny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54F039B7.5020800@samsung.com \
    --to=j.anaszewski@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=gjasny@googlemail.com \
    --cc=hans.verkuil@cisco.com \
    --cc=hdegoede@redhat.com \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=sakari.ailus@iki.fi \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.