lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Wed,  2 Mar 2016 20:38:19 -0700
From:	Shuah Khan <shuahkh@....samsung.com>
To:	mchehab@....samsung.com, hans.verkuil@...co.com,
	chehabrafael@...il.com, javier@....samsung.com
Cc:	Shuah Khan <shuahkh@....samsung.com>, linux-media@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH] media: au0828 audio mixer isn't connected to decoder

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 <shuahkh@....samsung.com>
Reported-by: Mauro Carvalho Chehab <mchehab@....samsung.com>
---

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;
-- 
2.5.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ