linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH v2] uvcvideo: Send control change events for slave ctrls when the master changes
Date: Tue, 24 Apr 2012 15:08:18 +0200	[thread overview]
Message-ID: <4F96A5C2.3070704@redhat.com> (raw)
In-Reply-To: <1335221282-14176-1-git-send-email-laurent.pinchart@ideasonboard.com>

Hi,

Good optimization, ACK.

Regards,

Hans

On 04/24/2012 12:48 AM, Laurent Pinchart wrote:
> From: Hans de Goede<hdegoede@redhat.com>
>
> This allows v4l2 control UI-s to update the inactive state (ie grey-ing
> out of controls) for slave controls when the master control changes.
>
> Signed-off-by: Hans de Goede<hdegoede@redhat.com>
> [Use __uvc_find_control() to find slave controls, as they're always
> located in the same entity as the corresponding master control]
> Signed-off-by: Laurent Pinchart<laurent.pinchart@ideasonboard.com>
> ---
>   drivers/media/video/uvc/uvc_ctrl.c |   58 ++++++++++++++++++++++++++++++++++-
>   1 files changed, 56 insertions(+), 2 deletions(-)
>
> Hi Hans,
>
> This is your 09/10 patch after replacing uvc_find_control() with
> __uvc_find_control(). Could you please test it ?
>
> diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
> index ae7371f..03212c7 100644
> --- a/drivers/media/video/uvc/uvc_ctrl.c
> +++ b/drivers/media/video/uvc/uvc_ctrl.c
> @@ -1177,21 +1177,75 @@ static void uvc_ctrl_send_event(struct uvc_fh *handle,
>
>   	list_for_each_entry(sev,&mapping->ev_subs, node)
>   		if (sev->fh&&  (sev->fh !=&handle->vfh ||
> -		    (sev->flags&  V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK)))
> +		    (sev->flags&  V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK) ||
> +		    (changes&  V4L2_EVENT_CTRL_CH_FLAGS)))
>   			v4l2_event_queue_fh(sev->fh,&ev);
>   }
>
> +static void uvc_ctrl_send_slave_event(struct uvc_fh *handle,
> +	struct uvc_control *master, u32 slave_id,
> +	const struct v4l2_ext_control *xctrls, unsigned int xctrls_count)
> +{
> +	struct uvc_control_mapping *mapping = NULL;
> +	struct uvc_control *ctrl = NULL;
> +	u32 changes = V4L2_EVENT_CTRL_CH_FLAGS;
> +	unsigned int i;
> +	s32 val = 0;
> +
> +	/*
> +	 * We can skip sending an event for the slave if the slave
> +	 * is being modified in the same transaction.
> +	 */
> +	for (i = 0; i<  xctrls_count; i++) {
> +		if (xctrls[i].id == slave_id)
> +			return;
> +	}
> +
> +	__uvc_find_control(master->entity, slave_id,&mapping,&ctrl, 0);
> +	if (ctrl == NULL)
> +		return;
> +
> +	if (__uvc_ctrl_get(handle->chain, ctrl, mapping,&val) == 0)
> +		changes |= V4L2_EVENT_CTRL_CH_VALUE;
> +
> +	uvc_ctrl_send_event(handle, ctrl, mapping, val, changes);
> +}
> +
>   static void uvc_ctrl_send_events(struct uvc_fh *handle,
>   	const struct v4l2_ext_control *xctrls, unsigned int xctrls_count)
>   {
>   	struct uvc_control_mapping *mapping;
>   	struct uvc_control *ctrl;
> +	u32 changes = V4L2_EVENT_CTRL_CH_VALUE;
>   	unsigned int i;
> +	unsigned int j;
>
>   	for (i = 0; i<  xctrls_count; ++i) {
>   		ctrl = uvc_find_control(handle->chain, xctrls[i].id,&mapping);
> +
> +		for (j = 0; j<  ARRAY_SIZE(mapping->slave_ids); ++j) {
> +			if (!mapping->slave_ids[j])
> +				break;
> +			uvc_ctrl_send_slave_event(handle, ctrl,
> +						  mapping->slave_ids[j],
> +						  xctrls, xctrls_count);
> +		}
> +
> +		/*
> +		 * If the master is being modified in the same transaction
> +		 * flags may change too.
> +		 */
> +		if (mapping->master_id) {
> +			for (j = 0; j<  xctrls_count; j++) {
> +				if (xctrls[j].id == mapping->master_id) {
> +					changes |= V4L2_EVENT_CTRL_CH_FLAGS;
> +					break;
> +				}
> +			}
> +		}
> +
>   		uvc_ctrl_send_event(handle, ctrl, mapping, xctrls[i].value,
> -				    V4L2_EVENT_CTRL_CH_VALUE);
> +				    changes);
>   	}
>   }
>

  reply	other threads:[~2012-04-24 13:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-08 15:59 [PATCH 00/10] uvcvideo: Add support for control events (v2) Hans de Goede
2012-04-08 15:59 ` [PATCH 01/10] media/radio: use v4l2_ctrl_subscribe_event where possible Hans de Goede
2012-04-08 15:59 ` [PATCH 02/10] v4l2-event: Add v4l2_subscribed_event_ops Hans de Goede
2012-04-08 15:59 ` [PATCH 03/10] v4l2-ctrls: Use v4l2_subscribed_event_ops Hans de Goede
2012-04-08 15:59 ` [PATCH 04/10] uvcvideo: Fix a "ignoring return value of ‘__clear_user’" warning Hans de Goede
2012-04-08 15:59 ` [PATCH 05/10] uvcvideo: Refactor uvc_ctrl_get and query Hans de Goede
2012-04-08 15:59 ` [PATCH 06/10] uvcvideo: Move __uvc_ctrl_get() up Hans de Goede
2012-04-08 15:59 ` [PATCH 07/10] uvcvideo: Add support for control events Hans de Goede
2012-04-08 15:59 ` [PATCH 08/10] uvcvideo: Properly report the inactive flag for inactive controls Hans de Goede
2012-04-08 15:59 ` [PATCH 09/10] uvcvideo: Send control change events for slave ctrls when the master changes Hans de Goede
2012-04-23 22:18   ` Laurent Pinchart
2012-04-23 22:48     ` [PATCH v2] " Laurent Pinchart
2012-04-24 13:08       ` Hans de Goede [this message]
2012-04-08 15:59 ` [PATCH 10/10] uvcvideo: Drop unused ctrl member from struct uvc_control_mapping Hans de Goede
2012-04-23 18:08 ` [PATCH 00/10] uvcvideo: Add support for control events (v2) Laurent Pinchart

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=4F96A5C2.3070704@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /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 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).