From patchwork Fri Feb 5 16:04:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 8236621 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 724ADBEEE5 for ; Fri, 5 Feb 2016 16:06:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 806A420389 for ; Fri, 5 Feb 2016 16:06:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3595620383 for ; Fri, 5 Feb 2016 16:06:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754184AbcBEQGT (ORCPT ); Fri, 5 Feb 2016 11:06:19 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:55734 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753644AbcBEQGT (ORCPT ); Fri, 5 Feb 2016 11:06:19 -0500 Received: from [191.249.97.8] (helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1aRitl-0007xf-IF; Fri, 05 Feb 2016 16:06:17 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.86) (envelope-from ) id 1aRisY-00049O-5l; Fri, 05 Feb 2016 14:05:02 -0200 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab Subject: [PATCH 5/6] [media] v4l2-mc: add an ancillary routine for PCI-based MC Date: Fri, 5 Feb 2016 14:04:59 -0200 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: To: unlisted-recipients:; (no To-header on input) 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Instead of copyping the same code on all PCI devices that would have a media controller, add a core ancillary routine. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-mc.c | 35 +++++++++++++++++++++++++++++++++++ include/media/v4l2-mc.h | 24 +++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index 7276dbbbe830..e8dc3cfac666 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -15,9 +15,44 @@ */ #include +#include #include #include + +struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev, + char *name) +{ +#ifdef CONFIG_PCI + struct media_device *mdev; + + mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); + if (!mdev) + return NULL; + + mdev->dev = &pci_dev->dev; + + if (name) + strlcpy(mdev->model, name, sizeof(mdev->model)); + else + strlcpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model)); + + sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev)); + + mdev->hw_revision = pci_dev->subsystem_vendor << 16 + || pci_dev->subsystem_device; + + mdev->driver_version = LINUX_VERSION_CODE; + + media_device_init(mdev); + + return mdev; +#else + return NULL; +#endif +} +EXPORT_SYMBOL_GPL(v4l2_mc_pci_media_device_init); + int v4l2_mc_create_media_graph(struct media_device *mdev) { diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h index 3097493e6cf1..18bcdbb300d4 100644 --- a/include/media/v4l2-mc.h +++ b/include/media/v4l2-mc.h @@ -92,6 +92,10 @@ enum demod_pad_index { DEMOD_NUM_PADS }; + +struct pci_dev; /* We don't need to include pci.h here */ + +#ifdef CONFIG_MEDIA_CONTROLLER /** * v4l2_mc_create_media_graph() - create Media Controller links at the graph. * @@ -106,10 +110,28 @@ enum demod_pad_index { * interface centric PC-consumer's hardware, V4L2 subdev centric camera * hardware should not use this routine, as it will not build the right graph. */ -#ifdef CONFIG_MEDIA_CONTROLLER int v4l2_mc_create_media_graph(struct media_device *mdev); + +/** + * v4l2_mc_pci_media_device_init() - create and initialize a + * struct &media_device from a PCI device. + * + * @pci_dev: pointer to struct pci_dev + * @name: media device name. If %NULL, the routine will use the default + * name for the pci device, given by pci_name() macro. + */ +struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev, + char *name); + + #else static inline int v4l2_mc_create_media_graph(struct media_device *mdev) { return 0; } + +struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev, + char *name) { + return NULL; +} + #endif