From patchwork Sat Apr 30 13:28:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 743362 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p3UDRuWL030490 for ; Sat, 30 Apr 2011 13:27:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756796Ab1D3N1m (ORCPT ); Sat, 30 Apr 2011 09:27:42 -0400 Received: from perceval.ideasonboard.com ([95.142.166.194]:57236 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756619Ab1D3N1l (ORCPT ); Sat, 30 Apr 2011 09:27:41 -0400 Received: from localhost.localdomain (unknown [91.178.80.7]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9765635995 for ; Sat, 30 Apr 2011 13:27:40 +0000 (UTC) From: Laurent Pinchart To: linux-media@vger.kernel.org Subject: [PATCH 1/2] uvcvideo: Don't report unsupported menu entries Date: Sat, 30 Apr 2011 15:28:03 +0200 Message-Id: <1304170084-11733-1-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.3.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 30 Apr 2011 13:27:57 +0000 (UTC) Supported menu entries are reported by the device in response to the GET_RES query. Use the information to return -EINVAL to userspace for unsupported values when enumerating menu entries. Signed-off-by: Laurent Pinchart --- drivers/media/video/uvc/uvc_ctrl.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c index d6fe13d..0dc2a9f 100644 --- a/drivers/media/video/uvc/uvc_ctrl.c +++ b/drivers/media/video/uvc/uvc_ctrl.c @@ -1015,6 +1015,24 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain, } menu_info = &mapping->menu_info[query_menu->index]; + + if (ctrl->info.flags & UVC_CTRL_FLAG_GET_RES) { + s32 bitmap; + + if (!ctrl->cached) { + ret = uvc_ctrl_populate_cache(chain, ctrl); + if (ret < 0) + goto done; + } + + bitmap = mapping->get(mapping, UVC_GET_RES, + uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES)); + if (!(bitmap & menu_info->value)) { + ret = -EINVAL; + goto done; + } + } + strlcpy(query_menu->name, menu_info->name, sizeof query_menu->name); done: