From patchwork Tue Jul 31 17:02:13 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: 10551071 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 31FD413B8 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 1FC7F2B0C0 for ; Tue, 31 Jul 2018 17:02:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12ABD2B0F8; 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 ADA3E2B0B6 for ; Tue, 31 Jul 2018 17:02:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732211AbeGaSna (ORCPT ); Tue, 31 Jul 2018 14:43:30 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36648 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732074AbeGaSna (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=/GSqgqBV+8zgeKT7N6yBnetj+OQgcPJAmgJarbd5zGc=; b=dA95o0M08dZydDikHKE4GvMrl PylD7uQAwHf5u6ArYaq66g4srX1ZbvbXqeg1GtIqciiCZIUmlq7jpaYLlxwWr7H4TdxMIoVNRVk8S Yk2sqkaV/CIGHnMgYRykrN1ediG3oqZnBvCggX61OrYAQbwcmQkD2p84soMMyPVlM/wQND4PPywBZ +tMVUbohp/Op2zxvI/+M05YWylEW6PkyDprzE7vvBKnnN+6Be7zfGCEFjW3dByCEQp6Ntwq3xg6sD ZnEyzrQJrKccWqB3Zgt8QQR/y/qw+LrJ4XJqQQpUJqctxDnfWkgOMg8diERRPcKdkL/7nkV0YVPOi zV8v2u3OQ==; 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-0002ap-Oz; Tue, 31 Jul 2018 17:02:17 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.91) (envelope-from ) id 1fkY2J-0007cM-DE; Tue, 31 Jul 2018 14:02:15 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab Subject: [PATCH RFC 4/4] media: dvb: use signals to discover pads Date: Tue, 31 Jul 2018 14:02:13 -0300 Message-Id: <012ee8bc9d1832843ee2c410f05bfb29560f1e42.1533055990.git.mchehab+samsung@kernel.org> 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 On tuner pads, multiple signals are present. Be sure to get the right PAD by using them. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-core/dvbdev.c | 37 +++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 787fe06df217..5c39bd328835 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -607,6 +607,28 @@ static int dvb_create_io_intf_links(struct dvb_adapter *adap, return 0; } +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 dvb_create_media_graph(struct dvb_adapter *adap, bool create_rf_connector) { @@ -618,7 +640,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap, unsigned demux_pad = 0; unsigned dvr_pad = 0; unsigned ntuner = 0, ndemod = 0; - int ret; + int ret, pad_source, pad_sink; static const char *connector_name = "Television"; if (!mdev) @@ -678,7 +700,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap, if (ret) return ret; - if (!ntuner) + if (!ntuner) { ret = media_create_pad_links(mdev, MEDIA_ENT_F_CONN_RF, conn, 0, @@ -686,19 +708,26 @@ int dvb_create_media_graph(struct dvb_adapter *adap, demod, 0, MEDIA_LNK_FL_ENABLED, false); - else + } else { + pad_sink = get_pad_index(tuner, true, PAD_SIGNAL_RF); + if (pad_sink < 0) + return -EINVAL; ret = media_create_pad_links(mdev, MEDIA_ENT_F_CONN_RF, conn, 0, MEDIA_ENT_F_TUNER, - tuner, TUNER_PAD_RF_INPUT, + tuner, pad_sink, MEDIA_LNK_FL_ENABLED, false); + } if (ret) return ret; } if (ntuner && ndemod) { + pad_source = get_pad_index(tuner, true, PAD_SIGNAL_RF); + if (pad_source) + return -EINVAL; ret = media_create_pad_links(mdev, MEDIA_ENT_F_TUNER, tuner, TUNER_PAD_OUTPUT,