From patchwork Tue Jul 31 17:02:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10551073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B568B1822 for ; Tue, 31 Jul 2018 17:02:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A35F22B0B6 for ; Tue, 31 Jul 2018 17:02:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 978012B0F8; Tue, 31 Jul 2018 17:02:20 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 1A0F72B0B6 for ; Tue, 31 Jul 2018 17:02:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732074AbeGaSnb (ORCPT ); Tue, 31 Jul 2018 14:43:31 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36652 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732141AbeGaSna (ORCPT ); Tue, 31 Jul 2018 14:43:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=97E6XDfQ4Uquyp7QOkv1kSqTY+O4/V13vrd24eWn8NA=; b=CRdjRdSRISykCUuPUk+sVtOTH 0VwsmZkutq7lQeT9H5EXtxznr+9F5cDwPV+feW2ZnV1M0Lo2wezkgZPu3xEut+NAvO5z6vO73Q21b phnguqZI3E5vsc0Y4wjR7lnv84sDQpmzNVUMX9pTq0xTU5jdhupWia4PaUOMWv9QXrmvikGgOtpeJ KnMeV+UX4kUzk07FbhVuM7lY65skfM/hAX7NAcbqnfDEqNB/p4R7wGF1HXLcjAOUelkEeR7geOzZ7 k1acyl/LikWFYnQy7cv+u2OpMylJDpMbxOp/K4VZdkctPUcMznDtaZW7lvMAcNbDb6JarmS67DYat 5R9a/ZqWA==; Received: from [179.182.165.210] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fkY2L-0002ar-QJ; Tue, 31 Jul 2018 17:02:17 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.91) (envelope-from ) id 1fkY2J-0007cI-Bi; Tue, 31 Jul 2018 14:02:15 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Shuah Khan , Pravin Shedge , Hans Verkuil , Laurent Pinchart Subject: [PATCH RFC 3/4] v4l2-mc: switch it to use the new approach to setup pipelines Date: Tue, 31 Jul 2018 14:02:12 -0300 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 Instead of relying on a static map for pids, use the new sig_type "taint" type to setup the pipelines with the same tipe between different entities. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-mc.c | 87 +++++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 16 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index 982bab3530f6..8640f656f9ae 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -19,6 +19,28 @@ #include #include +static int get_pad_index(struct media_entity *entity, bool is_sink, + enum media_pad_signal_type sig_type) +{ + int i; + bool pad_is_sink; + + for (i = 0; i < entity->num_pads; i++) { + if (entity->pads[i].flags == MEDIA_PAD_FL_SINK) + pad_is_sink = true; + else if (entity->pads[i].flags == MEDIA_PAD_FL_SOURCE) + pad_is_sink = false; + else + continue; /* This is an error! */ + + if (pad_is_sink != is_sink) + continue; + if (entity->pads[i].sig_type == sig_type) + return i; + } + return -EINVAL; +} + int v4l2_mc_create_media_graph(struct media_device *mdev) { @@ -28,7 +50,7 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) struct media_entity *io_v4l = NULL, *io_vbi = NULL, *io_swradio = NULL; bool is_webcam = false; u32 flags; - int ret; + int ret, pad_sink, pad_source; if (!mdev) return 0; @@ -97,29 +119,48 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) /* Link the tuner and IF video output pads */ if (tuner) { if (if_vid) { - ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT, - if_vid, - IF_VID_DEC_PAD_IF_INPUT, + pad_source = get_pad_index(tuner, false, PAD_SIGNAL_RF); + pad_sink = get_pad_index(if_vid, true, PAD_SIGNAL_RF); + if (pad_source < 0 || pad_sink < 0) + return -EINVAL; + ret = media_create_pad_link(tuner, pad_source, + if_vid, pad_sink, MEDIA_LNK_FL_ENABLED); if (ret) return ret; - ret = media_create_pad_link(if_vid, IF_VID_DEC_PAD_OUT, - decoder, DEMOD_PAD_IF_INPUT, + + pad_source = get_pad_index(if_vid, false, + PAD_SIGNAL_ATV_VIDEO); + pad_sink = get_pad_index(decoder, true, + PAD_SIGNAL_ATV_VIDEO); + if (pad_source < 0 || pad_sink < 0) + return -EINVAL; + ret = media_create_pad_link(if_vid, pad_source, + decoder, pad_sink, MEDIA_LNK_FL_ENABLED); if (ret) return ret; } else { - ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT, - decoder, DEMOD_PAD_IF_INPUT, + pad_source = get_pad_index(tuner, false, PAD_SIGNAL_RF); + pad_sink = get_pad_index(decoder, true, PAD_SIGNAL_RF); + if (pad_source < 0 || pad_sink < 0) + return -EINVAL; + ret = media_create_pad_link(tuner, pad_source, + decoder, pad_sink, MEDIA_LNK_FL_ENABLED); if (ret) return ret; } if (if_aud) { - ret = media_create_pad_link(tuner, TUNER_PAD_AUD_OUT, - if_aud, - IF_AUD_DEC_PAD_IF_INPUT, + pad_source = get_pad_index(tuner, false, + PAD_SIGNAL_AUDIO); + pad_sink = get_pad_index(decoder, true, + PAD_SIGNAL_AUDIO); + if (pad_source < 0 || pad_sink < 0) + return -EINVAL; + ret = media_create_pad_link(tuner, pad_source, + if_aud, pad_sink, MEDIA_LNK_FL_ENABLED); if (ret) return ret; @@ -131,7 +172,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) /* Create demod to V4L, VBI and SDR radio links */ if (io_v4l) { - ret = media_create_pad_link(decoder, DEMOD_PAD_VID_OUT, + pad_source = get_pad_index(tuner, false, PAD_SIGNAL_ATV_VIDEO); + if (pad_source < 0) + return -EINVAL; + ret = media_create_pad_link(decoder, pad_source, io_v4l, 0, MEDIA_LNK_FL_ENABLED); if (ret) @@ -139,7 +183,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) } if (io_swradio) { - ret = media_create_pad_link(decoder, DEMOD_PAD_VID_OUT, + pad_source = get_pad_index(tuner, false, PAD_SIGNAL_ATV_VIDEO); + if (pad_source < 0) + return -EINVAL; + ret = media_create_pad_link(decoder, pad_source, io_swradio, 0, MEDIA_LNK_FL_ENABLED); if (ret) @@ -147,7 +194,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) } if (io_vbi) { - ret = media_create_pad_link(decoder, DEMOD_PAD_VID_OUT, + pad_source = get_pad_index(tuner, false, PAD_SIGNAL_ATV_VIDEO); + if (pad_source < 0) + return -EINVAL; + ret = media_create_pad_link(decoder, pad_source, io_vbi, 0, MEDIA_LNK_FL_ENABLED); if (ret) @@ -161,13 +211,18 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) case MEDIA_ENT_F_CONN_RF: if (!tuner) continue; - + pad_source = get_pad_index(tuner, false, PAD_SIGNAL_RF); + if (pad_source < 0) + return -EINVAL; ret = media_create_pad_link(entity, 0, tuner, - TUNER_PAD_RF_INPUT, + pad_source, flags); break; case MEDIA_ENT_F_CONN_SVIDEO: case MEDIA_ENT_F_CONN_COMPOSITE: + pad_sink = get_pad_index(decoder, true, PAD_SIGNAL_RF); + if (pad_sink < 0) + return -EINVAL; ret = media_create_pad_link(entity, 0, decoder, DEMOD_PAD_IF_INPUT, flags);