From patchwork Fri Dec 15 07:56:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 10114135 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 3FCB660327 for ; Fri, 15 Dec 2017 07:57:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31F0C29F11 for ; Fri, 15 Dec 2017 07:57:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26C2F29F17; Fri, 15 Dec 2017 07:57:07 +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=ham 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 A7C2029F11 for ; Fri, 15 Dec 2017 07:57:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754170AbdLOH5D (ORCPT ); Fri, 15 Dec 2017 02:57:03 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:41325 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753922AbdLOH45 (ORCPT ); Fri, 15 Dec 2017 02:56:57 -0500 Received: by mail-pg0-f65.google.com with SMTP id o2so5287682pgc.8 for ; Thu, 14 Dec 2017 23:56:57 -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=5cjIEjY/rCQm4pP0K4VqM1V8BawwuMerLFewyvhVFBo=; b=gS3pezxaV8GPTo5SZIuYaeGkvdwZ70ioFrMFrRDElnfxJKNP/N9EimD4FR7wQJwa5y b8qKX9ZYWqP/FsAnsOvk1ID6sGtLf3wHaVHXnE9mGEz+xbG2iNt8dOkF++JM67kzI7DE BfUFCXhycxdhnu4t3Rap+yWl1iX8Gixz68T4g= 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=5cjIEjY/rCQm4pP0K4VqM1V8BawwuMerLFewyvhVFBo=; b=sY+BNSjiPYm770ZsFH7YocVh8otxTaj7jJEMCltoJLfwYVOSN2JGO0TyLLe3xG1mVK q4miHSVKfMLeB4qMm4CbXwbGJN9VvWsVuoKrq4rCEsfqfTMSqenJvf230G2Jdqt+9ZWX HfEcmgktbtSMqw0O5+rAOOQyS4UbxBDFqDmrgjXnL+EPDvJpoAypESLQ4MexjBU4SVMY xd3OuU+fjKvkV7XsF3eo4OtCAUr7H7lEztW0UtpxBUi2g4ZzrPaL8APlE4Z1xurOSUMX N/YPnX6f2HX/1ewNKYqwRPaasqMpvulnhWEYXJtxuL3Jc4MPskm3aZTMwBELn2OtxNT4 WBwQ== X-Gm-Message-State: AKGB3mKR/bquuqi13YLFE0C5pnhnFZAWlmkFHWVhXLS8MN7skZYQjFvU bqLzPfb6Ky3UdvQ/M8gUfSdhUg== X-Google-Smtp-Source: ACJfBos2AqA4Quuzl7hC8ejK7yhrz2paKIlGnINKUIpeQNkLsnWZhzdkUbyhJv0zo5LjZPmyhXlaMA== X-Received: by 10.99.65.135 with SMTP id o129mr11112308pga.81.1513324617188; Thu, 14 Dec 2017 23:56:57 -0800 (PST) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:1002:a6cd:a898:e07b:a331]) by smtp.gmail.com with ESMTPSA id 69sm11645509pfj.28.2017.12.14.23.56.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 23:56:56 -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: [RFC PATCH 3/9] media: request: add generic entity ops Date: Fri, 15 Dec 2017 16:56:19 +0900 Message-Id: <20171215075625.27028-4-acourbot@chromium.org> X-Mailer: git-send-email 2.15.1.504.g5279b80103-goog In-Reply-To: <20171215075625.27028-1-acourbot@chromium.org> References: <20171215075625.27028-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 skeleton ops for generic entities. The intent is to provide a generic mechanism to apply request parameters to entities using regular media/v4l2 functions. Signed-off-by: Alexandre Courbot --- drivers/media/Makefile | 3 +- drivers/media/media-request-entity-generic.c | 56 ++++++++++++++++++++++++++++ include/media/media-request.h | 5 +++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 drivers/media/media-request-entity-generic.c diff --git a/drivers/media/Makefile b/drivers/media/Makefile index 90117fff1339..dea482f6ab72 100644 --- a/drivers/media/Makefile +++ b/drivers/media/Makefile @@ -4,7 +4,8 @@ # media-objs := media-device.o media-devnode.o media-entity.o \ - media-request.o media-request-queue-generic.o + media-request.o media-request-queue-generic.o \ + media-request-entity-generic.o # # I2C drivers should come before other drivers, otherwise they'll fail diff --git a/drivers/media/media-request-entity-generic.c b/drivers/media/media-request-entity-generic.c new file mode 100644 index 000000000000..18e53f9ce525 --- /dev/null +++ b/drivers/media/media-request-entity-generic.c @@ -0,0 +1,56 @@ +/* + * Media generic entity ops + * + * Copyright (C) 2017, 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 +#include + +struct media_request_entity_data_generic { + struct media_request_entity_data base; +}; + +static struct media_request_entity_data * +alloc_req_data(struct media_request *req, struct media_entity *entity) +{ + struct media_request_entity_data_generic *ret; + + ret = kzalloc(sizeof(*ret), GFP_KERNEL); + if (!ret) + return ERR_PTR(-ENOMEM); + + return &ret->base; +} + +static void release_req_data(struct media_request_entity_data *_data) +{ + struct media_request_entity_data_generic *data; + + data = container_of(_data, typeof(*data), base); + kfree(data); +} + +static int apply_req_data(struct media_request_entity_data *_data) +{ + return 0; +} + +const struct media_request_entity_ops +media_entity_request_generic_ops = { + .alloc_data = alloc_req_data, + .release_data = release_req_data, + .apply_data = apply_req_data, +}; +EXPORT_SYMBOL_GPL(media_entity_request_generic_ops); diff --git a/include/media/media-request.h b/include/media/media-request.h index 583a1116f735..de3d6d824ffd 100644 --- a/include/media/media-request.h +++ b/include/media/media-request.h @@ -240,6 +240,11 @@ struct media_request_entity_ops { int (*apply_data)(struct media_request_entity_data *data); }; +/* + * Generic entity request support, built on top of standard V4L2 functions + */ +extern const struct media_request_entity_ops media_entity_request_generic_ops; + /** * media_device_request_cmd() - perform the REQUEST_CMD ioctl *