From patchwork Tue Feb 20 04:44:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 10229331 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 3FF8D60392 for ; Tue, 20 Feb 2018 04:45:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EC3626E3C for ; Tue, 20 Feb 2018 04:45:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21A4328382; Tue, 20 Feb 2018 04:45:57 +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 772D326E3C for ; Tue, 20 Feb 2018 04:45:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751672AbeBTEpn (ORCPT ); Mon, 19 Feb 2018 23:45:43 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:45404 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751600AbeBTEpl (ORCPT ); Mon, 19 Feb 2018 23:45:41 -0500 Received: by mail-pf0-f196.google.com with SMTP id j24so2063970pff.12 for ; Mon, 19 Feb 2018 20:45:41 -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=JhgA+KoNb5ohbCrrs/Ilo/8lK231i7GBDhCbRFibYTI=; b=JGJWD8J8zsatWA6HaEdJz37YlSpqxRFJ+rdFpvIf+BirtDXTabOe0EWZVwVZ4Oi5O0 Tq8sit1oLIaFwIC76fI0oItoTvTpHmBYUmNOQf9i3xS0SpLdbhgF8CI3NMDboljreJ1a cngSP9pZO3k08i9eqp14zsW7J2RAlUOciMc7s= 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=JhgA+KoNb5ohbCrrs/Ilo/8lK231i7GBDhCbRFibYTI=; b=UPoU3nURS9V7dkUULfgmWDnnuHKOb4AWq5ckIJjqLLCEaBXXpRBp1Fc5FeAApHdoZc u2gx0NByqSiqSVKbu7MTxOv443eclMd6cgo+wwR+IHX1NPS9IL4nVlx8wUT3PirFpIsI BWYk4rarIU+kDYHjfgvhvHdMepWb24ECZxHvdyXDJRRoolT1eGxWqYNVh/fBVRV3+EyU bMbEKrzrO5lQJdpdbVmA6zYmGeB1D6HwFcQ+KzFkU/van8D86RBoZchALVEXr+Z9wYK1 gjrxA/0pvNuzEF5YNrBdnkaAs9wrnHK+Zb/yU13da0N/tmoEFjS/9dGwnS6STPhCzJIS 7FmQ== X-Gm-Message-State: APf1xPB01vyhcZ5nM9g/2xMuQPnUEsUK3I7vJLfV1odDwnHHhOp2zNY7 Tpo6fqKhPLPWvxupMV2PwfBPTw== X-Google-Smtp-Source: AH8x225cVHVY6yigeftEjkwF94HrYOByDYfiuxF0QEE7R2A/hKIt0FSuiHWfs1OWgJSOMKfbnSOeUQ== X-Received: by 10.101.97.175 with SMTP id i15mr13799601pgv.55.1519101940709; Mon, 19 Feb 2018 20:45:40 -0800 (PST) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:1002:a6cd:a898:e07b:a331]) by smtp.gmail.com with ESMTPSA id q9sm783397pgs.28.2018.02.19.20.45.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Feb 2018 20:45:40 -0800 (PST) From: Alexandre Courbot To: Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Pawel Osciak , Marek Szyprowski , Tomasz Figa , Sakari Ailus Cc: Gustavo Padovan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot Subject: [RFCv4 21/21] [WIP] media: media-device: support for creating requests Date: Tue, 20 Feb 2018 13:44:25 +0900 Message-Id: <20180220044425.169493-22-acourbot@chromium.org> X-Mailer: git-send-email 2.16.1.291.g4437f3f132-goog In-Reply-To: <20180220044425.169493-1-acourbot@chromium.org> References: <20180220044425.169493-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 new MEDIA_IOC_NEW_REQUEST ioctl, which can be used to instantiate a request suitable to control the media device topology as well as the parameters and buffer flow of its entities. This is still very early work, and mainly here to demonstrate that it is still possible to bind requests to media entities. Signed-off-by: Alexandre Courbot --- drivers/media/media-device.c | 11 +++++++++++ include/media/mc-request.h | 33 +++++++++++++++++++++++++++++++++ include/media/media-device.h | 1 + include/media/media-entity.h | 5 +++++ include/uapi/linux/media.h | 2 ++ 5 files changed, 52 insertions(+) create mode 100644 include/media/mc-request.h diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index e79f72b8b858..2fb8b9c5ec85 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef CONFIG_MEDIA_CONTROLLER @@ -359,6 +360,15 @@ static long media_device_get_topology(struct media_device *mdev, return ret; } +static long media_device_new_request(struct media_device *mdev, + struct media_request_new *new) +{ + if (!mdev->req_mgr) + return -ENOTTY; + + return media_request_ioctl_new(mdev->req_mgr, new); +} + static long copy_arg_from_user(void *karg, void __user *uarg, unsigned int cmd) { /* All media IOCTLs are _IOWR() */ @@ -407,6 +417,7 @@ static const struct media_ioctl_info ioctl_info[] = { MEDIA_IOC(ENUM_LINKS, media_device_enum_links, MEDIA_IOC_FL_GRAPH_MUTEX), MEDIA_IOC(SETUP_LINK, media_device_setup_link, MEDIA_IOC_FL_GRAPH_MUTEX), MEDIA_IOC(G_TOPOLOGY, media_device_get_topology, MEDIA_IOC_FL_GRAPH_MUTEX), + MEDIA_IOC(NEW_REQUEST, media_device_new_request, 0), }; static long media_device_ioctl(struct file *filp, unsigned int cmd, diff --git a/include/media/mc-request.h b/include/media/mc-request.h new file mode 100644 index 000000000000..c14d38a93019 --- /dev/null +++ b/include/media/mc-request.h @@ -0,0 +1,33 @@ +/* + * Media requests support for media controller + * + * 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_MC_REQUEST_H +#define _MEDIA_MC_REQUEST_H + +#include +#include + +#if IS_ENABLED(CONFIG_MEDIA_REQUEST_API) + +struct mc_request_entity { + struct media_request_entity base; + struct media_entity *entity; +}; + +#else /* CONFIG_MEDIA_REQUEST_API */ + +#endif /* CONFIG_MEDIA_REQUEST_API */ + +#endif diff --git a/include/media/media-device.h b/include/media/media-device.h index bcc6ec434f1f..e931e8b9f60e 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -127,6 +127,7 @@ struct media_device { /* dev->driver_data points to this struct. */ struct device *dev; struct media_devnode *devnode; + struct media_request_mgr *req_mgr; char model[32]; char driver_name[32]; diff --git a/include/media/media-entity.h b/include/media/media-entity.h index a732af1dbba0..e3525d1ec386 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -26,6 +26,8 @@ #include #include +struct mc_request_entity; + /* Enums used internally at the media controller to represent graphs */ /** @@ -243,6 +245,7 @@ enum media_entity_type { * re-used if entities are unregistered or registered again. * @pads: Pads array with the size defined by @num_pads. * @links: List of data links. + * @req_entity: Pointer to the request entity representing this entity, if any * @ops: Entity operations. * @stream_count: Stream count for the entity. * @use_count: Use count for the entity. @@ -279,6 +282,8 @@ struct media_entity { struct media_pad *pads; struct list_head links; + struct mc_request_entity *req_entity; + const struct media_entity_operations *ops; int stream_count; diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index b9b9446095e9..eb0014c4eb40 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h @@ -30,6 +30,7 @@ #include #include #include +#include struct media_device_info { char driver[16]; @@ -413,5 +414,6 @@ struct media_v2_topology { #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum) #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc) #define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology) +#define MEDIA_IOC_NEW_REQUEST _IOR('|', 0x05, struct media_request_new) #endif /* __LINUX_MEDIA_H */