From patchwork Wed Feb 7 01:48:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 10204487 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F26826020F for ; Wed, 7 Feb 2018 01:51:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3E2628D86 for ; Wed, 7 Feb 2018 01:51:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D869628D8B; Wed, 7 Feb 2018 01:51:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B99228D86 for ; Wed, 7 Feb 2018 01:51:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752832AbeBGBuv (ORCPT ); Tue, 6 Feb 2018 20:50:51 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:42628 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753106AbeBGBtG (ORCPT ); Tue, 6 Feb 2018 20:49:06 -0500 Received: by mail-pl0-f67.google.com with SMTP id 11so2489798plc.9 for ; Tue, 06 Feb 2018 17:49:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Yc8Vs2npO1zpKN/2KWC2o3ekqbf+QBeY9yD038MolcY=; b=iXB3zJ1xlydRkDhe+WqgCvXyegSrLDzpWknpsrMIasYaFLqUZn0E37MP7qnQmQYemK EQqzUe/BnrOvIpRMBM9F73i3e4je4R5vz/vLo9bdxYR39nqbHuO+Yjndm1A8dC/5g5qO U0imOfh11bCIy86dDspWjCWU7FH0MqyQans+A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Yc8Vs2npO1zpKN/2KWC2o3ekqbf+QBeY9yD038MolcY=; b=HRms2TMRLLpc3RqWQuSueSu+/AQktUVtKKc5+k+zw992/gJTP6sDgNA33OmdQbpr1j 15jGW5R8qWi5VGXVuvMfqKaxviDgwPa7GliWCAafRLuS97u+HwvDQSKLFukKHys4oxCo CnOCQwPMn6nSbtdBLMWlOlIKeMlqS88glceptbl8DyKCnMOyubaolyb+Gi+8A8G0G1QG p1gD854kgNFLxCKwpqSGF/N/TS3o2o3fDqs6TT73ob9oEhE6zVpoS4a1BFDjsQSqA10b 7YhL7+1TDXXFNiy1HrrXPLmavkpEkf9tW1tKvpRA3X6wTgp6/EkmsYeA8BotDDMD+8C1 1PEw== X-Gm-Message-State: APf1xPCAGY17Vo3EsW0H6eU6DtzIKXvkFK/Djuo0x2+dzSA9YUI49Dy1 /aLkjMQu8dyra0RNPQmcQfub6g== X-Google-Smtp-Source: AH8x227tXyBnbXVIVTuHHHvbAmPQ4iySShch0C9talSHN3vRYlNImpjJGh2WQlsgzbLVU7MQR8LDXA== X-Received: by 2002:a17:902:8b88:: with SMTP id ay8-v6mr4251261plb.197.1517968146322; Tue, 06 Feb 2018 17:49:06 -0800 (PST) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:1002:a6cd:a898:e07b:a331]) by smtp.gmail.com with ESMTPSA id x26sm528060pfi.141.2018.02.06.17.49.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Feb 2018 17:49:05 -0800 (PST) From: Alexandre Courbot To: Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Pawel Osciak , Marek Szyprowski , Tomasz Figa , Sakari Ailus , Gustavo Padovan Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot Subject: [RFCv3 12/17] v4l2: add request API support Date: Wed, 7 Feb 2018 10:48:16 +0900 Message-Id: <20180207014821.164536-13-acourbot@chromium.org> X-Mailer: git-send-email 2.16.0.rc1.238.g530d649a79-goog In-Reply-To: <20180207014821.164536-1-acourbot@chromium.org> References: <20180207014821.164536-1-acourbot@chromium.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a v4l2 request entity data structure that takes care of storing the request-related state of a V4L2 device ; in this case, its controls. Signed-off-by: Alexandre Courbot --- drivers/media/v4l2-core/Makefile | 2 +- drivers/media/v4l2-core/v4l2-request.c | 54 ++++++++++++++++++++++++++++++++++ include/media/v4l2-request.h | 34 +++++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 drivers/media/v4l2-core/v4l2-request.c create mode 100644 include/media/v4l2-request.h diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile index 80de2cb9c476..1113dea1f4f9 100644 --- a/drivers/media/v4l2-core/Makefile +++ b/drivers/media/v4l2-core/Makefile @@ -15,7 +15,7 @@ obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o ifeq ($(CONFIG_TRACEPOINTS),y) videodev-objs += vb2-trace.o v4l2-trace.o endif -videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o +videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o v4l2-request.o obj-$(CONFIG_VIDEO_V4L2) += videodev.o obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o diff --git a/drivers/media/v4l2-core/v4l2-request.c b/drivers/media/v4l2-core/v4l2-request.c new file mode 100644 index 000000000000..7bc29d3cc332 --- /dev/null +++ b/drivers/media/v4l2-core/v4l2-request.c @@ -0,0 +1,54 @@ +/* + * Media requests support for V4L2 + * + * Copyright (C) 2018, The Chromium OS Authors. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include + +#include + +struct media_request_entity_data *media_request_v4l2_entity_data_alloc( + struct v4l2_ctrl_handler *hdl) +{ + struct media_request_v4l2_entity_data *data; + int ret; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + + ret = v4l2_ctrl_request_init(&data->ctrls); + if (ret) { + kfree(data); + return ERR_PTR(ret); + } + + ret = v4l2_ctrl_request_clone(&data->ctrls, hdl, NULL); + if (ret) { + kfree(data); + return ERR_PTR(ret); + } + + return &data->base; +} +EXPORT_SYMBOL_GPL(media_request_v4l2_entity_data_alloc); + +void +media_request_v4l2_entity_data_free(struct media_request_entity_data *_data) +{ + struct media_request_v4l2_entity_data *data; + + data = to_v4l2_entity_data(_data); + + v4l2_ctrl_handler_free(&data->ctrls); + kfree(data); +} +EXPORT_SYMBOL_GPL(media_request_v4l2_entity_data_free); diff --git a/include/media/v4l2-request.h b/include/media/v4l2-request.h new file mode 100644 index 000000000000..db38dc5fc460 --- /dev/null +++ b/include/media/v4l2-request.h @@ -0,0 +1,34 @@ +/* + * Media requests support for V4L2 + * + * Copyright (C) 2018, The Chromium OS Authors. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _MEDIA_REQUEST_V4L2_H +#define _MEDIA_REQUEST_V4L2_H + +#include +#include + +struct media_request_v4l2_entity_data { + struct media_request_entity_data base; + + struct v4l2_ctrl_handler ctrls; +}; +#define to_v4l2_entity_data(d) \ + container_of(d, struct media_request_v4l2_entity_data, base) + +struct media_request_entity_data *media_request_v4l2_entity_data_alloc( + struct v4l2_ctrl_handler *hdl); +void media_request_v4l2_entity_data_free(struct media_request_entity_data *data); + +#endif