From patchwork Wed Jan 23 22:21:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sylwester Nawrocki X-Patchwork-Id: 2027021 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2A8D0DF23E for ; Wed, 23 Jan 2013 22:22:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752325Ab3AWWWW (ORCPT ); Wed, 23 Jan 2013 17:22:22 -0500 Received: from mail-ee0-f48.google.com ([74.125.83.48]:62057 "EHLO mail-ee0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752259Ab3AWWWU (ORCPT ); Wed, 23 Jan 2013 17:22:20 -0500 Received: by mail-ee0-f48.google.com with SMTP id t10so4211190eei.7 for ; Wed, 23 Jan 2013 14:22:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=7QY65Id6o7KpGhhMpfOrFC6Yt1rrpR2moYKg5dh6Aco=; b=EUbRSgC6HyiRJkIKJpUf+Q1ufxckrRvUgp61+/9MjtAlygydBsRxZV7oQayEqD1dSJ OqK9TwhaItTTfZ1vbl6b7g6c/kDZChg6PsFYEHI9X++CsCg3zPgnNoz+nClDYMkkrq1d KyBCoQ8wjDcXBBeYEeeirMkhe69SSa95hy5KIZUDkGWR09La1oSm40nsFID9+yvw3zwA 6F6gLcUghW4MwD+Z6ewuRVZr6YX3mzGzRrT5s2zDvQUszUM9aIxtWiRfadPH9lMlealH r+AaJYgPER/CDILgh7Ufs0ygB50E+YFcrbdlGHDlEHyu7Fb4lFz8qqxCL8+qRXDB9A+N WNBw== X-Received: by 10.14.225.201 with SMTP id z49mr8584423eep.16.1358979738943; Wed, 23 Jan 2013 14:22:18 -0800 (PST) Received: from localhost.localdomain (031011138205.warszawa.vectranet.pl. [31.11.138.205]) by mx.google.com with ESMTPS id f49sm32606042eep.12.2013.01.23.14.22.17 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 23 Jan 2013 14:22:17 -0800 (PST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, sylvester.nawrocki@gmail.com Subject: [PATCH RFC v3 4/6] V4L: Add v4l2_ctrl_subdev_subscribe_event() helper function Date: Wed, 23 Jan 2013 23:21:59 +0100 Message-Id: <1358979721-17473-5-git-send-email-sylvester.nawrocki@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1358979721-17473-1-git-send-email-sylvester.nawrocki@gmail.com> References: <1358979721-17473-1-git-send-email-sylvester.nawrocki@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a v4l2 core helper function that can be used as the subdev .subscribe_event handler. This allows to eliminate some boilerplate from drivers that are only handling the control events. Signed-off-by: Sylwester Nawrocki --- drivers/media/v4l2-core/v4l2-ctrls.c | 9 +++++++++ include/media/v4l2-ctrls.h | 5 +++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 3f27571..9051ec5 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -2885,6 +2885,15 @@ int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh, } EXPORT_SYMBOL(v4l2_ctrl_subscribe_event); +int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, + struct v4l2_event_subscription *sub) +{ + if (!sd->ctrl_handler) + return -EINVAL; + return v4l2_ctrl_subscribe_event(fh, sub); +} +EXPORT_SYMBOL(v4l2_ctrl_subdev_subscribe_event); + unsigned int v4l2_ctrl_poll(struct file *file, struct poll_table_struct *wait) { struct v4l2_fh *fh = file->private_data; diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 91125b6..1e84946 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -654,4 +654,9 @@ int v4l2_subdev_s_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs int v4l2_subdev_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl); int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl); +/* Can be used as a subscribe_event function that just subscribes control + events. */ +int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, + struct v4l2_event_subscription *sub); + #endif