From patchwork Sat Aug 22 07:26:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 7055101 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 63AD39F358 for ; Sat, 22 Aug 2015 07:26:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D7F72069E for ; Sat, 22 Aug 2015 07:26:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 877062069B for ; Sat, 22 Aug 2015 07:26:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752262AbbHVH0N (ORCPT ); Sat, 22 Aug 2015 03:26:13 -0400 Received: from mail-la0-f47.google.com ([209.85.215.47]:33630 "EHLO mail-la0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751648AbbHVH0L (ORCPT ); Sat, 22 Aug 2015 03:26:11 -0400 Received: by lalv9 with SMTP id v9so52582836lal.0; Sat, 22 Aug 2015 00:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=yI+O90V0E/nrf6UMYvMFySW5PMFmMf8P5RsvsksvSss=; b=Ue7glDaLCEz+33YQDRBgldzhPXaIBvqSfvOlNXTpmkYKZRrPvkOfZin0XRNZWJLyRe oy41BgvF1ueU2gTYUvAFauxXED232x+CDV4Qv7EQBJQ+JTgCJMhB9swOCbOTvm054Zqh AaGeLDHWcHKv7SLdo3EZtbrZ3RqznLrfX8trYLO78xV/AXLCaeictYdFq2J9WpYtG4ca xMEOtxAJMdUs85I3lwykakJyf811k1FA66a1W8WfQwyOauyLRDOspGMKsQ56Wrz+CSTa ARapwDw7E3vfSByf5+IZxACPPxOxSXxVw2D7rBM0olePqXM8j5/QlgdaL++/MhkjdUgP tYCg== X-Received: by 10.112.140.104 with SMTP id rf8mr10382870lbb.30.1440228370147; Sat, 22 Aug 2015 00:26:10 -0700 (PDT) Received: from localhost.localdomain (x1-6-74-44-01-e3-62-1a.cpe.webspeed.dk. [80.167.115.215]) by smtp.gmail.com with ESMTPSA id lu1sm3027205lac.37.2015.08.22.00.26.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 22 Aug 2015 00:26:08 -0700 (PDT) From: Ricardo Ribalda Delgado To: Mauro Carvalho Chehab , Mike Isely , Laurent Pinchart , Hans Verkuil , Steven Toth , Sakari Ailus , Vincent Palatin , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH v3 07/10] media/usb/pvrusb2: Support for V4L2_CTRL_WHICH_DEF_VAL Date: Sat, 22 Aug 2015 09:26:06 +0200 Message-Id: <1440228366-18431-1-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This driver does not use the control infrastructure. Add support for the new field which on structure v4l2_ext_controls Acked-By: Mike Isely Signed-off-by: Ricardo Ribalda Delgado --- changes v3: By Mike Isely elevate the call to pvr2_hdw_get_ctrl_v4l() out of the if-statement drivers/media/usb/pvrusb2/pvrusb2-v4l2.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c index 1c5f85bf7ed4..81f788b7b242 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-v4l2.c @@ -628,6 +628,7 @@ static int pvr2_g_ext_ctrls(struct file *file, void *priv, struct pvr2_v4l2_fh *fh = file->private_data; struct pvr2_hdw *hdw = fh->channel.mc_head->hdw; struct v4l2_ext_control *ctrl; + struct pvr2_ctrl *cptr; unsigned int idx; int val; int ret; @@ -635,8 +636,15 @@ static int pvr2_g_ext_ctrls(struct file *file, void *priv, ret = 0; for (idx = 0; idx < ctls->count; idx++) { ctrl = ctls->controls + idx; - ret = pvr2_ctrl_get_value( - pvr2_hdw_get_ctrl_v4l(hdw, ctrl->id), &val); + cptr = pvr2_hdw_get_ctrl_v4l(hdw, ctrl->id); + if (cptr) { + if (ctls->which == V4L2_CTRL_WHICH_DEF_VAL) + pvr2_ctrl_get_def(cptr, &val); + else + ret = pvr2_ctrl_get_value(cptr, &val); + } else + ret = -EINVAL; + if (ret) { ctls->error_idx = idx; return ret; @@ -658,6 +666,10 @@ static int pvr2_s_ext_ctrls(struct file *file, void *priv, unsigned int idx; int ret; + /* Default value cannot be changed */ + if (ctls->which == V4L2_CTRL_WHICH_DEF_VAL) + return -EINVAL; + ret = 0; for (idx = 0; idx < ctls->count; idx++) { ctrl = ctls->controls + idx;