From patchwork Sat Sep 15 20:14:19 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: 10601579 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 12B501805 for ; Sat, 15 Sep 2018 20:14:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F41882A601 for ; Sat, 15 Sep 2018 20:14:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E87D32A62E; Sat, 15 Sep 2018 20:14:41 +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 64BD9294C7 for ; Sat, 15 Sep 2018 20:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727946AbeIPBes (ORCPT ); Sat, 15 Sep 2018 21:34:48 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:43394 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727291AbeIPBer (ORCPT ); Sat, 15 Sep 2018 21:34:47 -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=TwvHMP5DSpXUVE3mTM1LHfwtZxYrP12+o4uRLjiZgg8=; b=uujPWZXIj2zB2f+49ye5QC3HX ZN9wqdlk9Su/HqJ5EQ32hJqxwrTDP1kcdAffqotiLcgGdYp65c1hdcEj3WAjcmv8MBEUiZxqH2FGQ KqrpdaajUbESeiTXFoK9tocBaS5N8ywLFeo+oWt8HqLawAedA1WI22CE/irutBdrScqP+lEpF7h8V DspGrrJjAMGhgveSKwef1ExIzynD60oZoA0T4kpDE+RjrOkQA54DmW0i3kXWjT4ePqf2rPZL1kjOa u46pQP4gE1h/FLNY8HCNOCgCJeUYuTUnLyFA6DAcPMQOMVbg5cI6pZsSOcrOJ4b9IQi4vr67c4IB2 Ac3xC7mHw==; Received: from [179.95.0.169] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g1Gxe-0002P6-Jw; Sat, 15 Sep 2018 20:14:35 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.91) (envelope-from ) id 1g1Gxb-0008Rt-SG; Sat, 15 Sep 2018 17:14:31 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Hans Verkuil , Shuah Khan , Pravin Shedge , Laurent Pinchart Subject: [PATCH v2 04/14] media: v4l2-mc: add print messages when media graph fails Date: Sat, 15 Sep 2018 17:14:19 -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 It is not trivial to debug troubles at media graph build. So, add print messages to help debug what's happening, in the case of an error occurs. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-mc.c | 80 +++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index 3d868f071dd7..03f41c3fb8ec 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -63,8 +63,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) } /* It should have at least one I/O entity */ - if (!io_v4l && !io_vbi && !io_swradio) + if (!io_v4l && !io_vbi && !io_swradio) { + dev_warn(mdev->dev, "Didn't find any I/O entity\n"); return -EINVAL; + } /* * Here, webcams are modelled on a very simple way: the sensor is @@ -74,8 +76,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) * PC-consumer's hardware. */ if (is_webcam) { - if (!io_v4l) + if (!io_v4l) { + dev_warn(mdev->dev, "Didn't find a MEDIA_ENT_F_IO_V4L\n"); return -EINVAL; + } media_device_for_each_entity(entity, mdev) { if (entity->function != MEDIA_ENT_F_CAM_SENSOR) @@ -83,16 +87,20 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) ret = media_create_pad_link(entity, 0, io_v4l, 0, MEDIA_LNK_FL_ENABLED); - if (ret) + if (ret) { + dev_warn(mdev->dev, "Failed to create a sensor link\n"); return ret; + } } if (!decoder) return 0; } /* The device isn't a webcam. So, it should have a decoder */ - if (!decoder) + if (!decoder) { + dev_warn(mdev->dev, "Decoder not found\n"); return -EINVAL; + } /* Link the tuner and IF video output pads */ if (tuner) { @@ -101,32 +109,45 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) PAD_SIGNAL_ANALOG); pad_sink = media_get_pad_index(if_vid, true, PAD_SIGNAL_ANALOG); - if (pad_source < 0 || pad_sink < 0) + if (pad_source < 0 || pad_sink < 0) { + dev_warn(mdev->dev, "Couldn't get tuner and/or PLL pad(s): (%d, %d)\n", + pad_source, pad_sink); return -EINVAL; + } ret = media_create_pad_link(tuner, pad_source, if_vid, pad_sink, MEDIA_LNK_FL_ENABLED); - if (ret) + if (ret) { + dev_warn(mdev->dev, "Couldn't create tuner->PLL link)\n"); return ret; + } pad_source = media_get_pad_index(if_vid, false, PAD_SIGNAL_ANALOG); pad_sink = media_get_pad_index(decoder, true, PAD_SIGNAL_ANALOG); - if (pad_source < 0 || pad_sink < 0) + if (pad_source < 0 || pad_sink < 0) { + dev_warn(mdev->dev, "get decoder and/or PLL pad(s): (%d, %d)\n", + pad_source, pad_sink); return -EINVAL; + } ret = media_create_pad_link(if_vid, pad_source, decoder, pad_sink, MEDIA_LNK_FL_ENABLED); - if (ret) + if (ret) { + dev_warn(mdev->dev, "couldn't link PLL to decoder\n"); return ret; + } } else { pad_source = media_get_pad_index(tuner, false, PAD_SIGNAL_ANALOG); pad_sink = media_get_pad_index(decoder, true, PAD_SIGNAL_ANALOG); - if (pad_source < 0 || pad_sink < 0) + if (pad_source < 0 || pad_sink < 0) { + dev_warn(mdev->dev, "couldn't get tuner and/or decoder pad(s): (%d, %d)\n", + pad_source, pad_sink); return -EINVAL; + } ret = media_create_pad_link(tuner, pad_source, decoder, pad_sink, MEDIA_LNK_FL_ENABLED); @@ -139,13 +160,18 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) PAD_SIGNAL_AUDIO); pad_sink = media_get_pad_index(if_aud, true, PAD_SIGNAL_AUDIO); - if (pad_source < 0 || pad_sink < 0) + if (pad_source < 0 || pad_sink < 0) { + dev_warn(mdev->dev, "couldn't get tuner and/or decoder pad(s) for audio: (%d, %d)\n", + pad_source, pad_sink); return -EINVAL; + } ret = media_create_pad_link(tuner, pad_source, if_aud, pad_sink, MEDIA_LNK_FL_ENABLED); - if (ret) + if (ret) { + dev_warn(mdev->dev, "couldn't link tuner->audio PLL\n"); return ret; + } } else { if_aud = tuner; } @@ -155,35 +181,47 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) /* Create demod to V4L, VBI and SDR radio links */ if (io_v4l) { pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV); - if (pad_source < 0) + if (pad_source < 0) { + dev_warn(mdev->dev, "couldn't get decoder output pad for V4L I/O\n"); return -EINVAL; + } ret = media_create_pad_link(decoder, pad_source, io_v4l, 0, MEDIA_LNK_FL_ENABLED); - if (ret) + if (ret) { + dev_warn(mdev->dev, "couldn't link decoder output to V4L I/O\n"); return ret; + } } if (io_swradio) { pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV); - if (pad_source < 0) + if (pad_source < 0) { + dev_warn(mdev->dev, "couldn't get decoder output pad for SDR\n"); return -EINVAL; + } ret = media_create_pad_link(decoder, pad_source, io_swradio, 0, MEDIA_LNK_FL_ENABLED); - if (ret) + if (ret) { + dev_warn(mdev->dev, "couldn't link decoder output to SDR\n"); return ret; + } } if (io_vbi) { pad_source = media_get_pad_index(decoder, false, PAD_SIGNAL_DV); - if (pad_source < 0) + if (pad_source < 0) { + dev_warn(mdev->dev, "couldn't get decoder output pad for VBI\n"); return -EINVAL; + } ret = media_create_pad_link(decoder, pad_source, io_vbi, 0, MEDIA_LNK_FL_ENABLED); - if (ret) + if (ret) { + dev_warn(mdev->dev, "couldn't link decoder output to VBI\n"); return ret; + } } /* Create links for the media connectors */ @@ -195,8 +233,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) continue; pad_sink = media_get_pad_index(tuner, true, PAD_SIGNAL_ANALOG); - if (pad_sink < 0) + if (pad_sink < 0) { + dev_warn(mdev->dev, "couldn't get tuner analog pad sink\n"); return -EINVAL; + } ret = media_create_pad_link(entity, 0, tuner, pad_sink, flags); @@ -205,8 +245,10 @@ int v4l2_mc_create_media_graph(struct media_device *mdev) case MEDIA_ENT_F_CONN_COMPOSITE: pad_sink = media_get_pad_index(decoder, true, PAD_SIGNAL_ANALOG); - if (pad_sink < 0) + if (pad_sink < 0) { + dev_warn(mdev->dev, "couldn't get tuner analog pad sink\n"); return -EINVAL; + } ret = media_create_pad_link(entity, 0, decoder, pad_sink, flags);