From patchwork Tue Jan 15 19:15:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10765011 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 3A2C61580 for ; Tue, 15 Jan 2019 19:16:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 278A92BC51 for ; Tue, 15 Jan 2019 19:16:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19CA72BCEA; Tue, 15 Jan 2019 19:16:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A99502BC51 for ; Tue, 15 Jan 2019 19:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731596AbfAOTQB (ORCPT ); Tue, 15 Jan 2019 14:16:01 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43751 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729645AbfAOTQB (ORCPT ); Tue, 15 Jan 2019 14:16:01 -0500 Received: by mail-pg1-f195.google.com with SMTP id v28so1628070pgk.10; Tue, 15 Jan 2019 11:16:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LSIvMbrzQ+UiCLW5oK5dOF6+LjL9c2wUmS0an25CZk0=; b=Vk/w5vgpkw7oegUt97yOlHTwWb8RpKjY4HlMUTaMJw91+UNjZv73B8Rvdc8PVeB/Gc XEJRiNUBMVmRFiZA4YONkfqn5an8kaQu5tJLGTaBoCdVnCbOTSwrKZqqCjDdPtCBb+UA TEi/agUCriR1iYk9wj1St9VD7I1e5LNpzSdPgF8jEWvWMKdYoVGQC80MD3lbtHo2mf55 g0f3VGzvMKliIW4Mg0lQT3kl0tm9ggqNHbH+55ftc1k4i7tvH0T7zLMsmepfEdpSQg6G B2nNmVgYTqgD9MaCi07yJW6/D4Ic+aMKJd2FUiW9ybMc1g8iSss/1GX4I4bGWbpIQJUG GHwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LSIvMbrzQ+UiCLW5oK5dOF6+LjL9c2wUmS0an25CZk0=; b=oAOh05hubw/x5KXtn8Evc0lTZYhTO0Uy1eKFySxJziBqDijQEl2ySx5sKHxbMFXuGq ODO74y7uuJmAbckHGqlo6sOmrljv7teb/OBVmIytP37a0nSWj0+UsfeTPO99AgYgCcmu XuCQWDwIOzdaM859AmBgxLl9xkjPbxuMPbUAuBhh6fi1YFS4m1mUm75Pjyu0s0B/xdub 1ZbaPn2623gxP3Xr8dovHBOR1dMu5yCrRyro+cNfgjimSsTG2xZ7VBvUBoyBwWgcBjiE jHDnT3oYbXebHe1ZzU5NIenZ6ODRftAsbCgZNj4XjJu0q1MnFNtsjbWD22xDh5koA1g0 ReyA== X-Gm-Message-State: AJcUukd8q5sd9m4hVw2sTPtGR4S+Q4S20uGhh8RAcHSLRHnksFKz+Hqj toMAik861k2kVhQuAQdDeRHC2TpriJw= X-Google-Smtp-Source: ALg8bN65Ym86TBzuNv5yvZCO8350EbD8o1hzCYqo9/9vq+f2p7r2548NDorns1XsGa0q1nFzZb4JNg== X-Received: by 2002:a63:5ec6:: with SMTP id s189mr4939295pgb.357.1547579759906; Tue, 15 Jan 2019 11:15:59 -0800 (PST) Received: from majic.sklembedded.com (c-73-202-231-77.hsd1.ca.comcast.net. [73.202.231.77]) by smtp.googlemail.com with ESMTPSA id r80sm5452724pfa.111.2019.01.15.11.15.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 11:15:59 -0800 (PST) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] media: imx: queue subdev events to reachable video devices Date: Tue, 15 Jan 2019 11:15:46 -0800 Message-Id: <20190115191546.12975-1-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 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 In order to receive events generated by subdevices on the video capture nodes, those events need to be forwarded to the subdevice's list of reachable video capture devices. Note this will queue the event to a video device even if there is no actual _enabled_ media path from the sub-device to the video device. So a future improvement is to skip the video device if there is no enabled path to it from the sub-device. The entity->pipe pointer can't be used for this check because in imx-media a sub-device can be a member to more than one streaming pipeline at a time. Signed-off-by: Steve Longerbeam --- Changes in v2: - split out the implementation of (un)subscribe_event on the video capture device to a separate patch. --- drivers/staging/media/imx/imx-media-dev.c | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c index 4b344a4a3706..25e916562c66 100644 --- a/drivers/staging/media/imx/imx-media-dev.c +++ b/drivers/staging/media/imx/imx-media-dev.c @@ -442,6 +442,29 @@ static const struct media_device_ops imx_media_md_ops = { .link_notify = imx_media_link_notify, }; +static void imx_media_notify(struct v4l2_subdev *sd, + unsigned int notification, + void *arg) +{ + struct media_entity *entity = &sd->entity; + int i; + + if (notification != V4L2_DEVICE_NOTIFY_EVENT) + return; + + for (i = 0; i < entity->num_pads; i++) { + struct media_pad *pad = &entity->pads[i]; + struct imx_media_pad_vdev *pad_vdev; + struct list_head *pad_vdev_list; + + pad_vdev_list = to_pad_vdev_list(sd, pad->index); + if (!pad_vdev_list) + continue; + list_for_each_entry(pad_vdev, pad_vdev_list, list) + v4l2_event_queue(pad_vdev->vdev->vfd, arg); + } +} + static int imx_media_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -462,6 +485,7 @@ static int imx_media_probe(struct platform_device *pdev) mutex_init(&imxmd->mutex); imxmd->v4l2_dev.mdev = &imxmd->md; + imxmd->v4l2_dev.notify = imx_media_notify; strscpy(imxmd->v4l2_dev.name, "imx-media", sizeof(imxmd->v4l2_dev.name));