From patchwork Thu Mar 3 03:38:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 8487661 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 606AFC0553 for ; Thu, 3 Mar 2016 03:38:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7B26F20160 for ; Thu, 3 Mar 2016 03:38:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D68520270 for ; Thu, 3 Mar 2016 03:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753281AbcCCDiY (ORCPT ); Wed, 2 Mar 2016 22:38:24 -0500 Received: from mailout.easymail.ca ([64.68.201.169]:46158 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752980AbcCCDiX (ORCPT ); Wed, 2 Mar 2016 22:38:23 -0500 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 611E7EBEA; Wed, 2 Mar 2016 22:38:22 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at mailout.easymail.ca X-Spam-Score: -3.689 X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (easymail-mailout.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hyzV0LEMcuG8; Wed, 2 Mar 2016 22:38:21 -0500 (EST) Received: from mail.gonehiking.org (c-73-181-52-62.hsd1.co.comcast.net [73.181.52.62]) by mailout.easymail.ca (Postfix) with ESMTPA id BABD7EBB0; Wed, 2 Mar 2016 22:38:21 -0500 (EST) Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 208299F154; Wed, 2 Mar 2016 20:38:21 -0700 (MST) From: Shuah Khan To: mchehab@osg.samsung.com, hans.verkuil@cisco.com, chehabrafael@gmail.com, javier@osg.samsung.com Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: au0828 audio mixer isn't connected to decoder Date: Wed, 2 Mar 2016 20:38:19 -0700 Message-Id: <1456976299-7525-1-git-send-email-shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.5.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When snd_usb_audio gets probed first, audio mixer doesn't get linked to the decoder. Change au0828_media_graph_notify() to handle the mixer entity getting registered before the decoder. Change au0828_media_device_register() to invoke au0828_media_graph_notify() to connect entites that were created prior to registering the notify handler. Signed-off-by: Shuah Khan Reported-by: Mauro Carvalho Chehab --- Tested by black listing au0828 to force snd_usb_audio to load first and then modprobe au0828. Generated graphs to verify audio graph is connected to the au0828 graph. drivers/media/usb/au0828/au0828-core.c | 54 ++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index ca1e5eb..5821de4 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -211,23 +211,50 @@ static void au0828_media_graph_notify(struct media_entity *new, #ifdef CONFIG_MEDIA_CONTROLLER struct au0828_dev *dev = (struct au0828_dev *) notify_data; int ret; + struct media_entity *entity, *mixer = NULL, *decoder = NULL; - if (!dev->decoder) - return; + if (!new) { + /* + * Called during au0828 probe time to connect + * entites that were created prior to registering + * the notify handler. Find mixer and decoder. + */ + media_device_for_each_entity(entity, dev->media_dev) { + if (entity->function == MEDIA_ENT_F_AUDIO_MIXER) + mixer = entity; + else if (entity->function == MEDIA_ENT_F_ATV_DECODER) + decoder = entity; + } + goto create_link; + } switch (new->function) { case MEDIA_ENT_F_AUDIO_MIXER: - ret = media_create_pad_link(dev->decoder, + mixer = new; + if (dev->decoder) + decoder = dev->decoder; + break; + case MEDIA_ENT_F_ATV_DECODER: + /* In case, Mixer is added first, find mixer and create link */ + media_device_for_each_entity(entity, dev->media_dev) { + if (entity->function == MEDIA_ENT_F_AUDIO_MIXER) + mixer = entity; + } + decoder = new; + break; + default: + break; + } + +create_link: + if (decoder && mixer) { + ret = media_create_pad_link(decoder, AU8522_PAD_AUDIO_OUT, - new, 0, + mixer, 0, MEDIA_LNK_FL_ENABLED); if (ret) dev_err(&dev->usbdev->dev, - "Mixer Pad Link Create Error: %d\n", - ret); - break; - default: - break; + "Mixer Pad Link Create Error: %d\n", ret); } #endif } @@ -447,6 +474,15 @@ static int au0828_media_device_register(struct au0828_dev *dev, "Media Device Register Error: %d\n", ret); return ret; } + } else { + /* + * Call au0828_media_graph_notify() to connect + * audio graph to our graph. In this case, audio + * driver registered the device and there is no + * entity_notify to be called when new entities + * are added. Invoke it now. + */ + au0828_media_graph_notify(NULL, (void *) dev); } /* register entity_notify callback */ dev->entity_notify.notify_data = (void *) dev;