From patchwork Wed Aug 19 18:04:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 256076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92A46C433E1 for ; Wed, 19 Aug 2020 18:05:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FE4920882 for ; Wed, 19 Aug 2020 18:05:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="arbnsihp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726884AbgHSSFH (ORCPT ); Wed, 19 Aug 2020 14:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726875AbgHSSFC (ORCPT ); Wed, 19 Aug 2020 14:05:02 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55A69C061757 for ; Wed, 19 Aug 2020 11:05:02 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id mw10so1478453pjb.2 for ; Wed, 19 Aug 2020 11:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Sv87vM7p7z6RA/m4QyohJmK6RcFUCusmzqFQmHL0cjo=; b=arbnsihphQtZ1oi7VuwyfqLXA1f3iqIU6JchkF10yYvfiaOlgb5eOq6AkNTLRUojXw jQaTSQS+lkWibN1ozHgfUyLZPbpdfMFQ2Pc5PSUbnaY4iZTtpJOxfHDo2zu04mWsUjOc 6QEpwuu3SAiLHcdAAjkSk7XTXehCMkiPeDtMJsVkTaykVsDgEYOaB0CSrMMa+6jU2MGc 6X+Bq8XjUo0jsJhUl+JZ/Mw/L5dD4ZaWh7aNdcmz7RoPo9iVm1iCnoD5UXyj/bVQGE7U FpUfqNSP3rFhdeedKwbbsLBefIN3Xvl3zyn0PWwQpQm1mGwxhwCZvLxmGeswxT2xiVsu JOfw== 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:in-reply-to :references; bh=Sv87vM7p7z6RA/m4QyohJmK6RcFUCusmzqFQmHL0cjo=; b=N7isw4lqomXIvel5RkuBXhsb7Eefxpc1m9JiqHVxkMB5E6NlEmvoDf1F5RnfNsezVu cleEX61Km8y8+DXuNyVo5g8Ae2ligO4bOJSSZbNTnpB0fGPpbDDmEHQ5qplb+84f5P+S asy6fgiBLQYofq1PktNZvtqflQAwRbm3TY9WXb8pYtPqNTPR9sbZueqpGcCzKo2dIhb6 Q3FMWTql3V4jsfr7qQLbGv9ZiWAW/nfJ29vaCiw0goxRGL42pxk2CyptKyvOogEG7d/G 98q1Ab0wecq/TZQhY/wow+tHwv4ibeja8J3HwRuJp22T2+XeeWsKDBB2Kfi0OCIipRPG 5lXg== X-Gm-Message-State: AOAM530/WWgy8JLoEyoQGqd9aYe7YAagyJyGA3Tq9WppI6kAJZtd8Mrh VZf9CdlF3ofGn26uDN3ESU3r/Q== X-Google-Smtp-Source: ABdhPJzUmz9dXWmWwe06ZA+v+GGxWf/45X2KDEvKLzzrJ+r6CA5w/mS3u4y7I9NrxHdahBoYb6CSJQ== X-Received: by 2002:a17:90b:3597:: with SMTP id mm23mr4880234pjb.3.1597860301783; Wed, 19 Aug 2020 11:05:01 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.179]) by smtp.gmail.com with ESMTPSA id d22sm29422243pfd.42.2020.08.19.11.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:05:01 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham Cc: Kaaira Gupta Subject: [PATCH v3 1/9] media: vimc: Move get_source_entity to vimc-common Date: Wed, 19 Aug 2020 23:34:34 +0530 Message-Id: <20200819180442.11630-2-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819180442.11630-1-kgupta@es.iitr.ac.in> References: <20200819180442.11630-1-kgupta@es.iitr.ac.in> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Move the function vimc_get_source_entity() to vimc-common.c to make it reusable. Signed-off-by: Kaaira Gupta --- drivers/media/test-drivers/vimc/vimc-common.c | 14 +++++++++++ drivers/media/test-drivers/vimc/vimc-common.h | 12 ++++++++++ .../media/test-drivers/vimc/vimc-streamer.c | 24 ------------------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/media/test-drivers/vimc/vimc-common.c b/drivers/media/test-drivers/vimc/vimc-common.c index 0d97b25ce21e..91c8992bb391 100644 --- a/drivers/media/test-drivers/vimc/vimc-common.c +++ b/drivers/media/test-drivers/vimc/vimc-common.c @@ -417,3 +417,17 @@ int vimc_ent_sd_register(struct vimc_ent_device *ved, media_entity_cleanup(&sd->entity); return ret; } + +struct media_entity *vimc_get_source_entity(struct media_entity *ent) +{ + struct media_pad *pad; + int i; + + for (i = 0; i < ent->num_pads; i++) { + if (ent->pads[i].flags & MEDIA_PAD_FL_SOURCE) + continue; + pad = media_entity_remote_pad(&ent->pads[i]); + return pad ? pad->entity : NULL; + } + return NULL; +} diff --git a/drivers/media/test-drivers/vimc/vimc-common.h b/drivers/media/test-drivers/vimc/vimc-common.h index a289434e75ba..4c580d854007 100644 --- a/drivers/media/test-drivers/vimc/vimc-common.h +++ b/drivers/media/test-drivers/vimc/vimc-common.h @@ -230,4 +230,16 @@ int vimc_ent_sd_register(struct vimc_ent_device *ved, */ int vimc_vdev_link_validate(struct media_link *link); +/** + * vimc_get_source_entity - get the entity connected with the first sink pad + * + * @ent: reference media_entity + * + * Helper function that returns the media entity containing the source pad + * linked with the first sink pad from the given media entity pad list. + * + * Return: The source pad or NULL, if it wasn't found. + */ +struct media_entity *vimc_get_source_entity(struct media_entity *ent); + #endif diff --git a/drivers/media/test-drivers/vimc/vimc-streamer.c b/drivers/media/test-drivers/vimc/vimc-streamer.c index 451a32c0d034..4f8384246042 100644 --- a/drivers/media/test-drivers/vimc/vimc-streamer.c +++ b/drivers/media/test-drivers/vimc/vimc-streamer.c @@ -12,30 +12,6 @@ #include "vimc-streamer.h" -/** - * vimc_get_source_entity - get the entity connected with the first sink pad - * - * @ent: reference media_entity - * - * Helper function that returns the media entity containing the source pad - * linked with the first sink pad from the given media entity pad list. - * - * Return: The source pad or NULL, if it wasn't found. - */ -static struct media_entity *vimc_get_source_entity(struct media_entity *ent) -{ - struct media_pad *pad; - int i; - - for (i = 0; i < ent->num_pads; i++) { - if (ent->pads[i].flags & MEDIA_PAD_FL_SOURCE) - continue; - pad = media_entity_remote_pad(&ent->pads[i]); - return pad ? pad->entity : NULL; - } - return NULL; -} - /** * vimc_streamer_pipeline_terminate - Disable stream in all ved in stream * From patchwork Wed Aug 19 18:04:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 256075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22A31C433DF for ; Wed, 19 Aug 2020 18:05:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F181B20658 for ; Wed, 19 Aug 2020 18:05:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="Q8MbWudY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726886AbgHSSFe (ORCPT ); Wed, 19 Aug 2020 14:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726923AbgHSSFM (ORCPT ); Wed, 19 Aug 2020 14:05:12 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 462DEC061342 for ; Wed, 19 Aug 2020 11:05:12 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id d19so11765804pgl.10 for ; Wed, 19 Aug 2020 11:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VJOwxZD756f4d3HNd4Hpvhldk4W8KSHk0BSTu8cNd+0=; b=Q8MbWudYBHUtf3I/ngwkAVqIdwWbZXLatG/7b18xipE/k+EE9MX36XB+IV6lIDz+Br /GBMGIUAA4x5lZac1T1K9pRddO6E413r/7jUX2v8dMTPwpE26Ng2CBrBrGYDzSwmwmor 0sVjhNbFlZKmDjELnl2QpvUkUvBBEgHpTGUij2FQZF9Veuzx2opfvxfKBkkMm+dcK8gw 0dKMMeq+H4gqJS7OEXsyk2g5/2dfmwZeVMXRVU+RE27zG20TChgG+dz2GyFq2QKwoDdQ v/fUp8xgejoa264sKzFzTYoz5vQc+SMmgvMkPFy5SPIYorMT9c+YMsYc3PTckgfPYQQF fDJw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=VJOwxZD756f4d3HNd4Hpvhldk4W8KSHk0BSTu8cNd+0=; b=GywzY2u9YNeRFJhf9O2URMlrngG5hRHczrjif1n5wjR/LgcdDj0e6//aCBNijBTJ4Z Wf8aAmBxvORw9Sv5aZXbzRyicUQxQ5Dy05z87RBwqH4RxJYmetukUoO5bgCrGiRtLhLl rLqqtn4LqS1mCFN1dsadlTmbYpElgpEEf2DuGNWNZQUYe9rLPabP8LkY9eE9bK3iSddq n67m0C8Qpg6SD8tlujIhjVXwhsetjGPqfegtGgq8SW7myfP3i7h6ZrE3ZWXZJdtPBh89 op8DVkGd8QIQBsYjJmbBsQDYO9hPq+LQtnLYTz97OmLMSafqBLVZ/NFkXhqwOcmfrJ7q bw3w== X-Gm-Message-State: AOAM531gNQd7ec7Dim61GttW2MSruHzHdCX+wXtSWMEkcY74QLJJd3US RtBCyCw3DueweJMLI23Dh9EdszuVaTV8yQ== X-Google-Smtp-Source: ABdhPJzApiHr4zA8SCw8Y5N+Yqufm8PMxKzaoF12gzOBA8/fwujbFHlgOpVoA4yf/K9RAqfrd2W/9Q== X-Received: by 2002:a62:cd8f:: with SMTP id o137mr20689091pfg.241.1597860311717; Wed, 19 Aug 2020 11:05:11 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.179]) by smtp.gmail.com with ESMTPSA id w16sm29100810pfq.13.2020.08.19.11.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:05:11 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= , Kaaira Gupta Subject: [PATCH v3 3/9] media: vimc: Add usage count to subdevices Date: Wed, 19 Aug 2020 23:34:36 +0530 Message-Id: <20200819180442.11630-4-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819180442.11630-1-kgupta@es.iitr.ac.in> References: <20200819180442.11630-1-kgupta@es.iitr.ac.in> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Niklas Söderlund Prepare for multiple video streams from the same sensor by adding a use counter to vimc_ent_device. The counter is increased for every s_stream(1) and decremented for every s_stream(0) call. The subdevice stream is not started or stopped unless the usage count go from 0 to 1 (started) or from 1 to 0 (stopped). This allows for multiple s_stream() calls to try to either start or stop the device while only the first/last call will actually effect the state of the device. Initialise and increment use_count for capture as well, as use_count will be used in subsequent patches for starting process_frame as well. [Kaaira: moved use_count to vimc entity device instead of declaring it for each subdevice, used use_count for capture as well and rebased the patch on current HEAD of master to help with the current series] Signed-off-by: Niklas Söderlund Signed-off-by: Kaaira Gupta --- drivers/media/test-drivers/vimc/vimc-capture.c | 3 +++ drivers/media/test-drivers/vimc/vimc-common.h | 2 ++ drivers/media/test-drivers/vimc/vimc-debayer.c | 7 +++++++ drivers/media/test-drivers/vimc/vimc-scaler.c | 7 +++++++ drivers/media/test-drivers/vimc/vimc-sensor.c | 6 ++++++ 5 files changed, 25 insertions(+) diff --git a/drivers/media/test-drivers/vimc/vimc-capture.c b/drivers/media/test-drivers/vimc/vimc-capture.c index a8cbb8e4d5ba..93418cb5a139 100644 --- a/drivers/media/test-drivers/vimc/vimc-capture.c +++ b/drivers/media/test-drivers/vimc/vimc-capture.c @@ -243,6 +243,7 @@ static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count) struct media_entity *entity = &vcap->vdev.entity; int ret; + atomic_inc(&vcap->ved.use_count); vcap->sequence = 0; /* Start the media pipeline */ @@ -270,6 +271,7 @@ static void vimc_cap_stop_streaming(struct vb2_queue *vq) { struct vimc_cap_device *vcap = vb2_get_drv_priv(vq); + atomic_dec(&vcap->ved.use_count); vimc_streamer_s_stream(&vcap->stream, &vcap->ved, 0); /* Stop the media pipeline */ @@ -424,6 +426,7 @@ static struct vimc_ent_device *vimc_cap_add(struct vimc_device *vimc, vcap->vdev.entity.name = vcfg_name; vcap->vdev.entity.function = MEDIA_ENT_F_IO_V4L; vcap->pad.flags = MEDIA_PAD_FL_SINK; + atomic_set(&vcap->ved.use_count, 0); ret = media_entity_pads_init(&vcap->vdev.entity, 1, &vcap->pad); if (ret) diff --git a/drivers/media/test-drivers/vimc/vimc-common.h b/drivers/media/test-drivers/vimc/vimc-common.h index 287d66edff49..c214f5ec7818 100644 --- a/drivers/media/test-drivers/vimc/vimc-common.h +++ b/drivers/media/test-drivers/vimc/vimc-common.h @@ -85,6 +85,7 @@ struct vimc_pix_map { * * @dev: a pointer of the device struct of the driver * @ent: the pointer to struct media_entity for the node + * @use_count: a count to show the number of streams entity is part of * @get_frame: callback that sends a frame processed by the entity * @process_frame: callback that processes a frame * @vdev_get_format: callback that returns the current format a pad, used @@ -102,6 +103,7 @@ struct vimc_pix_map { struct vimc_ent_device { struct device *dev; struct media_entity *ent; + atomic_t use_count; void * (*get_frame)(struct vimc_ent_device *ved); int (*process_frame)(struct vimc_ent_device *ved); void (*vdev_get_format)(struct vimc_ent_device *ved, diff --git a/drivers/media/test-drivers/vimc/vimc-debayer.c b/drivers/media/test-drivers/vimc/vimc-debayer.c index f61e6e8899ac..60c4c0ec2030 100644 --- a/drivers/media/test-drivers/vimc/vimc-debayer.c +++ b/drivers/media/test-drivers/vimc/vimc-debayer.c @@ -343,6 +343,9 @@ static int vimc_deb_s_stream(struct v4l2_subdev *sd, int enable) const struct vimc_pix_map *vpix; unsigned int frame_size; + if (atomic_inc_return(&vdeb->ved.use_count) != 1) + return 0; + if (vdeb->src_frame) return 0; @@ -368,6 +371,9 @@ static int vimc_deb_s_stream(struct v4l2_subdev *sd, int enable) return -ENOMEM; } else { + if (atomic_dec_return(&vdeb->ved.use_count) != 0) + return 0; + if (!vdeb->src_frame) return 0; @@ -608,6 +614,7 @@ static struct vimc_ent_device *vimc_deb_add(struct vimc_device *vimc, vdeb->ved.get_frame = vimc_deb_get_frame; vdeb->ved.dev = vimc->mdev.dev; vdeb->mean_win_size = vimc_deb_ctrl_mean_win_size.def; + atomic_set(&vdeb->ved.use_count, 0); /* Initialize the frame format */ vdeb->sink_fmt = sink_fmt_default; diff --git a/drivers/media/test-drivers/vimc/vimc-scaler.c b/drivers/media/test-drivers/vimc/vimc-scaler.c index 347f9cd4a168..d511e1f2152d 100644 --- a/drivers/media/test-drivers/vimc/vimc-scaler.c +++ b/drivers/media/test-drivers/vimc/vimc-scaler.c @@ -340,6 +340,9 @@ static int vimc_sca_s_stream(struct v4l2_subdev *sd, int enable) const struct vimc_pix_map *vpix; unsigned int frame_size; + if (atomic_inc_return(&vsca->ved.use_count) != 1) + return 0; + if (vsca->src_frame) return 0; @@ -363,6 +366,9 @@ static int vimc_sca_s_stream(struct v4l2_subdev *sd, int enable) return -ENOMEM; } else { + if (atomic_dec_return(&vsca->ved.use_count) != 0) + return 0; + if (!vsca->src_frame) return 0; @@ -518,6 +524,7 @@ static struct vimc_ent_device *vimc_sca_add(struct vimc_device *vimc, vsca->ved.process_frame = vimc_sca_process_frame; vsca->ved.get_frame = vimc_sca_get_frame; vsca->ved.dev = vimc->mdev.dev; + atomic_set(&vsca->ved.use_count, 0); /* Initialize the frame format */ vsca->sink_fmt = sink_fmt_default; diff --git a/drivers/media/test-drivers/vimc/vimc-sensor.c b/drivers/media/test-drivers/vimc/vimc-sensor.c index 32a2c39de2cd..ced8ef06b01e 100644 --- a/drivers/media/test-drivers/vimc/vimc-sensor.c +++ b/drivers/media/test-drivers/vimc/vimc-sensor.c @@ -256,6 +256,9 @@ static int vimc_sen_s_stream(struct v4l2_subdev *sd, int enable) const struct vimc_pix_map *vpix; unsigned int frame_size; + if (atomic_inc_return(&vsen->ved.use_count) != 1) + return 0; + vsen->start_stream_ts = ktime_get_ns(); /* Calculate the frame size */ @@ -275,6 +278,8 @@ static int vimc_sen_s_stream(struct v4l2_subdev *sd, int enable) vimc_sen_tpg_s_format(vsen); } else { + if (atomic_dec_return(&vsen->ved.use_count) != 0) + return 0; vfree(vsen->frame); vsen->frame = NULL; @@ -437,6 +442,7 @@ static struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc, vsen->ved.process_frame = vimc_sen_process_frame; vsen->ved.get_frame = vimc_sen_get_frame; vsen->ved.dev = vimc->mdev.dev; + atomic_set(&vsen->ved.use_count, 0); /* Initialize the frame format */ vsen->mbus_format = fmt_default; From patchwork Wed Aug 19 18:04:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 256072 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F13BC433E4 for ; Wed, 19 Aug 2020 18:06:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F26320658 for ; Wed, 19 Aug 2020 18:06:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="BEFAAR8M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726935AbgHSSGa (ORCPT ); Wed, 19 Aug 2020 14:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726946AbgHSSFR (ORCPT ); Wed, 19 Aug 2020 14:05:17 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DE26C061757 for ; Wed, 19 Aug 2020 11:05:17 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id 2so1462204pjx.5 for ; Wed, 19 Aug 2020 11:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Myk1HtWNfMPMH6mEsQn60wKu3fbOFzXiNMNij+F/fos=; b=BEFAAR8MyoIxxx+igVHbbPaDJnsuviiG++309FQfr/cS43lp+JqFtnDa+7fDIohDbq w+T/a135DyuxywUD1oltM3KnNAV5z77uRsrpCagXQHy7//9nmOFnm/NziWqcmCdX2u4d x7sDD0GCrBENSmRxoiNj0JiFhbJc7Mp/t9dT94k+Vo9JQX5WeCDh2Psz8/fTMXdrjBEb 2jnod+/vh743GzLDstutDeiEIDFhKhIXEebwzc5vZteiKuiYckfhlkSa60J5oA4r27o+ LHkyzNYqXfd0tD5bOnAIbVyS2Xsbqv4epqrZAdtuHTbvLz6bIMok11bOkskvOVnfKEeE QAMg== 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:in-reply-to :references; bh=Myk1HtWNfMPMH6mEsQn60wKu3fbOFzXiNMNij+F/fos=; b=EBL+ihMnveH7CEOSHUaj/TxcHYfFLLx+5zYG50JbO4vwx1xl6+lFa94YAdiMWwN0PJ 4JqjVufGwDsDB/nKfAyQOPsvJUUbqKK8wst3ObjY2ngC+VI53ZhQdaFMq85hUG792TdN MZPf0nv+6lDsceG5R64gngF7q/luwQ3wknIkehgCZCLg2OvZJCbcfut/vLuJytD/BmOo MmUuV2/Azi+fxLcICNfz950/xLue5Z5gesbhxlHZqrizx4jHzCOMv3tx5QfMfxbsaFd4 9KvWCX6UKIahDYPSxhqd5SWeJ2OKAxaGMnsj5LSOXqsNJhUjvAXNBVbUhLYKwxpjQMd/ OC2A== X-Gm-Message-State: AOAM530AsA2Qti4olFVnyEUEiqoK+gs+HEYVgHgLeCETjmu2U5YVFU64 0GQ6lazAmpyNx8HrU4Llj/BRyw== X-Google-Smtp-Source: ABdhPJyCF6pSzhOSPzo3kzgKW1dmCArD3GflbjqS+gar3ADhQpRU4N4E7ONKEES3VzeqFSvr3z5nXw== X-Received: by 2002:a17:902:bc8a:: with SMTP id bb10mr19731292plb.74.1597860316960; Wed, 19 Aug 2020 11:05:16 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.179]) by smtp.gmail.com with ESMTPSA id z25sm29482106pfn.159.2020.08.19.11.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:05:15 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham Cc: Kaaira Gupta Subject: [PATCH v3 4/9] media: vimc: Separate starting stream from pipeline initialisation Date: Wed, 19 Aug 2020 23:34:37 +0530 Message-Id: <20200819180442.11630-5-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819180442.11630-1-kgupta@es.iitr.ac.in> References: <20200819180442.11630-1-kgupta@es.iitr.ac.in> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Separate the process of initialising pipeline array from starting streaming for all entities in path of a stream. This is needed because multiple streams can stream, but only one pipeline object is needed. Process frames only for those entities in a pipeline which are streaming. This is known through their use counts. Signed-off-by: Kaaira Gupta --- .../media/test-drivers/vimc/vimc-streamer.c | 95 ++++++++++++++++--- 1 file changed, 83 insertions(+), 12 deletions(-) diff --git a/drivers/media/test-drivers/vimc/vimc-streamer.c b/drivers/media/test-drivers/vimc/vimc-streamer.c index c1644d69686d..cc40ecabe95a 100644 --- a/drivers/media/test-drivers/vimc/vimc-streamer.c +++ b/drivers/media/test-drivers/vimc/vimc-streamer.c @@ -40,33 +40,30 @@ static void vimc_streamer_pipeline_terminate(struct vimc_stream *stream) } /** - * vimc_streamer_pipeline_init - Initializes the stream structure + * vimc_streamer_stream_start - Starts streaming for all entities + * in a stream * - * @stream: the pointer to the stream structure to be initialized * @ved: the pointer to the vimc entity initializing the stream * - * Initializes the stream structure. Walks through the entity graph to - * construct the pipeline used later on the streamer thread. - * Calls vimc_streamer_s_stream() to enable stream in all entities of - * the pipeline. + * Walks through the entity graph to call vimc_streamer_s_stream() + * to enable stream in all entities in path of a stream. * * Return: 0 if success, error code otherwise. */ -static int vimc_streamer_pipeline_init(struct vimc_stream *stream, - struct vimc_ent_device *ved) +static int vimc_streamer_stream_start(struct vimc_stream *stream, + struct vimc_ent_device *ved) { struct media_entity *entity; struct video_device *vdev; struct v4l2_subdev *sd; + int stream_size = 0; int ret = 0; - stream->pipe_size = 0; - while (stream->pipe_size < VIMC_STREAMER_PIPELINE_MAX_SIZE) { + while (stream_size < VIMC_STREAMER_PIPELINE_MAX_SIZE) { if (!ved) { vimc_streamer_pipeline_terminate(stream); return -EINVAL; } - stream->ved_pipeline[stream->pipe_size++] = ved; if (is_media_entity_v4l2_subdev(ved->ent)) { sd = media_entity_to_v4l2_subdev(ved->ent); @@ -104,6 +101,73 @@ static int vimc_streamer_pipeline_init(struct vimc_stream *stream, entity); ved = video_get_drvdata(vdev); } + stream_size++; + } + + vimc_streamer_pipeline_terminate(stream); + return -EINVAL; +} + +/** + * vimc_streamer_pipeline_init - Initialises pipeline and pipe size + * + * @stream: the pointer to the stream structure + * @ved: the pointer to the vimc entity initializing the stream pipeline + * + * Walks through the entity graph to initialise ved_pipeline and updates + * pipe_size too. + * + * Return: 0 if success, error code otherwise. + */ +static int vimc_streamer_pipeline_init(struct vimc_stream *stream, + struct vimc_ent_device *ved) +{ + struct media_entity *entity; + struct media_device *mdev; + struct media_graph graph; + struct video_device *vdev; + struct v4l2_subdev *sd; + int ret; + + entity = ved->ent; + mdev = entity->graph_obj.mdev; + + ret = media_graph_walk_init(&graph, mdev); + if (ret) + return ret; + + media_graph_walk_start(&graph, entity); + + /* + * Start pipeline array initialisation from RAW Capture only to get + * entities in the correct order of their frame processing. + */ + if (!strncmp(entity->name, "RGB", 3)) { + entity = media_graph_walk_next(&graph); + mdev = entity->graph_obj.mdev; + media_graph_walk_cleanup(&graph); + + ret = media_graph_walk_init(&graph, mdev); + if (ret) + return ret; + media_graph_walk_start(&graph, entity); + } + + while (stream->pipe_size < VIMC_STREAMER_PIPELINE_MAX_SIZE) { + if (is_media_entity_v4l2_subdev(entity)) { + sd = media_entity_to_v4l2_subdev(entity); + ved = v4l2_get_subdevdata(sd); + } else { + vdev = container_of(entity, struct video_device, entity); + ved = video_get_drvdata(vdev); + } + stream->ved_pipeline[stream->pipe_size++] = ved; + entity = media_graph_walk_next(&graph); + + if (!strcmp(entity->name, stream->ved_pipeline[0]->ent->name)) { + media_graph_walk_cleanup(&graph); + return 0; + } } vimc_streamer_pipeline_terminate(stream); @@ -138,8 +202,11 @@ static int vimc_streamer_thread(void *data) for (i = stream->pipe_size - 1; i >= 0; i--) { ved = stream->ved_pipeline[i]; - ret = ved->process_frame(ved); + if (atomic_read(&ved->use_count) == 0) + continue; + + ret = ved->process_frame(ved); if (ret) break; } @@ -179,6 +246,10 @@ int vimc_streamer_s_stream(struct vimc_stream *stream, if (stream->kthread) return 0; + ret = vimc_streamer_stream_start(stream, ved); + if (ret) + return ret; + ret = vimc_streamer_pipeline_init(stream, ved); if (ret) return ret; From patchwork Wed Aug 19 18:04:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 256073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24E7CC433DF for ; Wed, 19 Aug 2020 18:06:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 029CE20658 for ; Wed, 19 Aug 2020 18:06:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="pPiEj6mZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727086AbgHSSGQ (ORCPT ); Wed, 19 Aug 2020 14:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726983AbgHSSF3 (ORCPT ); Wed, 19 Aug 2020 14:05:29 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53EB4C061383 for ; Wed, 19 Aug 2020 11:05:29 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id h2so783842plr.0 for ; Wed, 19 Aug 2020 11:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PTx1KB4WomfJKMJISUl/NMNKsl0lboyI/6kyDO0ot0Q=; b=pPiEj6mZwpCKBOJjNus5Xgep/xDdXOmefZBNFxUJ0UkuxtFwSb7XiteXDD/RpgGXAr BtDEJWc5AdhX/vXUpOw+12FcNkAKUvzhMlI48wXzWp+WW1UEwmc9o7pM9AWh8dqIBS0w ZrK9bc1pxSOM9KL9OIjHF3orwkNxAaEqG+FnrPfu69Hma4U5VTk1wguOemxqhTIiqm2L upiwLu3nHLFx9jLs31fQ+jKAQiueaxsZBtGMBq/Hjheed++gxnRnuKJWk3AKIZMJ0xQj HNSwbGV4VXv9Yj5CY34Hh2c+Q62B8EZ/RaVBZDw4guBlx/HrhlmobCF3ZfZ7eOVK8UKy t1xQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=PTx1KB4WomfJKMJISUl/NMNKsl0lboyI/6kyDO0ot0Q=; b=ogn+agSy3DAd7xc4hr2kejT8+J/CKqdktDM0J0l1y81nU4B/35lBBc0sJgIbb/2VXo nrYXixum9gNkiQZP5rlmIoUeuyDrIyywwFcLgoTqItVxNG8f2k/+Oj6RP1xSuLUXCN8B fda5my9Dh/tgZBuVwGyW81vfkns1Wxrhfqx6Ao6/3kNP8jyc87xDdynr7fhb8pzDsUmI mNdKjVArWbxa1pz+j9oyeCN3P2Y1NT25+ZCycZFCWxtcymg3fQFVJWl8RUOuOnUg8fsq sxIpOs9qtxwg6yBBiIrXiaYgsASRjq9f6EIz2MsneqKtDu7hxfrt4vzfApLXo8/iXOSp Gqog== X-Gm-Message-State: AOAM530TedgvbD0BCL1k+v18q5EhDipB1F+4WN+XZJyxJ7e9NoVGUGJj 3+tRxMatgu6aeCMmVw7PttTftw== X-Google-Smtp-Source: ABdhPJyRHC2LN2rK2JG0ifUjrDVg3XtN1jTRkT7emzbh3uHC7nJPSWrn2om7LswmteBjqkTFI3drSA== X-Received: by 2002:a17:90b:23c9:: with SMTP id md9mr5114923pjb.173.1597860328786; Wed, 19 Aug 2020 11:05:28 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.179]) by smtp.gmail.com with ESMTPSA id u191sm24353638pgu.56.2020.08.19.11.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:05:28 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= , Kaaira Gupta Subject: [PATCH v3 6/9] media: vimc: Serialize vimc_streamer_s_stream() Date: Wed, 19 Aug 2020 23:34:39 +0530 Message-Id: <20200819180442.11630-7-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819180442.11630-1-kgupta@es.iitr.ac.in> References: <20200819180442.11630-1-kgupta@es.iitr.ac.in> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Niklas Söderlund Prepare for multiple video streams from the same sensor by serializing vimc_streamer_s_stream(). Multiple streams will allow for multiple concurrent calls to this function that could involve the same subdevices. If that happens the internal state of the involved subdevices could go out of sync as they are being started and stopped at the same time, prevent this by serializing starting and stopping of the vimc streamer. [Kaaira: only rebased the patch on current HEAD of media-tree] Signed-off-by: Niklas Söderlund Signed-off-by: Kaaira Gupta --- .../media/test-drivers/vimc/vimc-streamer.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/media/test-drivers/vimc/vimc-streamer.c b/drivers/media/test-drivers/vimc/vimc-streamer.c index 6b5ea1537952..f5c9e2f3bbcb 100644 --- a/drivers/media/test-drivers/vimc/vimc-streamer.c +++ b/drivers/media/test-drivers/vimc/vimc-streamer.c @@ -269,22 +269,27 @@ int vimc_streamer_s_stream(struct vimc_stream *stream, struct vimc_ent_device *ved, int enable) { + static DEFINE_MUTEX(vimc_streamer_lock); int ret; if (!stream || !ved) return -EINVAL; + ret = mutex_lock_interruptible(&vimc_streamer_lock); + if (ret) + return ret; + if (enable) { if (stream->kthread) return 0; ret = vimc_streamer_stream_start(ved); if (ret) - return ret; + goto out; ret = vimc_streamer_pipeline_init(stream, ved); if (ret) - return ret; + goto out; stream->kthread = kthread_run(vimc_streamer_thread, stream, "vimc-streamer thread"); @@ -294,17 +299,16 @@ int vimc_streamer_s_stream(struct vimc_stream *stream, dev_err(ved->dev, "kthread_run failed with %d\n", ret); vimc_streamer_stream_terminate(ved); vimc_streamer_pipeline_terminate(stream); - stream->kthread = NULL; - return ret; } } else { if (!stream->kthread) - return 0; + goto out; vimc_streamer_stream_terminate(ved); vimc_streamer_pipeline_terminate(stream); } - - return 0; +out: + mutex_unlock(&vimc_streamer_lock); + return ret; } From patchwork Wed Aug 19 18:04:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaaira Gupta X-Patchwork-Id: 256074 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55CF6C433DF for ; Wed, 19 Aug 2020 18:06:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3653C20658 for ; Wed, 19 Aug 2020 18:06:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=es-iitr-ac-in.20150623.gappssmtp.com header.i=@es-iitr-ac-in.20150623.gappssmtp.com header.b="DAYZaEy8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726987AbgHSSFr (ORCPT ); Wed, 19 Aug 2020 14:05:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727036AbgHSSFn (ORCPT ); Wed, 19 Aug 2020 14:05:43 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0727C061383 for ; Wed, 19 Aug 2020 11:05:42 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id y10so9639389plr.11 for ; Wed, 19 Aug 2020 11:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=es-iitr-ac-in.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I7Vn+tJdn/z3Gni7/IFrsXgR9xBszu9wFJcFR8d7t7c=; b=DAYZaEy86+xUJSGKApxyGOw1UJsAyjFkzMLM5tSg7n2TcH2yRwDqVl0cjq3+FBqSA1 /rnPQh63tAwDge5VU8SR1vv0qKuje10IoqObeSEiAz3siLzce6e+Cv7UL0XNeFhzAEaw dinBxzAhcZlbdv8B+vDAnpD97Oefe7d4exSRz4g9obzEdBPXx7xwCdDFm5KqSZLjNSKv qBAxfA+xiMm4NugXUax/c5nuyBeszPMMostAdQcq0txo9xXH//20g6guUIAUQVqyZjlJ +KW1RCsZyNtyrSF4NnKa9U/sslH+g8I8H9x45oXuBDQCguoObxbsPVhoEwTGpmZ9MrnV q/Cg== 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:in-reply-to :references; bh=I7Vn+tJdn/z3Gni7/IFrsXgR9xBszu9wFJcFR8d7t7c=; b=lLPLhyK1Z3frUak0RmUuknq40l6DLpKtprt2EeV12tFbFiJXytbbSACe/Exmm7yyv5 xNHYGupmYKrBSHqh1Y8U7AZj2vqJTk91BaFmngvckl6GrZYBhfNsNkuy3oLgvwuiPVua X3lXo7mAr1z7gRQemK4vkyKZOFKJ5EZizmJXbqjVreflNmPFFbBhKerp22JAjD39xHkE z8S6GF9TPuTdKBE33czu6NtY/xn/X1YVmy76paahLrCvoBxZnEhkI0XzVVvwXugRA2Eh 0HNNgntqx6I28TQqPU4JhcO1N+6c4OrbkiiiZluC/IS+Upkzf77PPMt/WAtOgXM8rsd0 o3WQ== X-Gm-Message-State: AOAM531xWsQXhkj8uk2obrOVMty3GlKZB9lCdu80rrgxo2LLtJ7CCyzz MVzguAKmE4duiylk7iX1E9hWKg== X-Google-Smtp-Source: ABdhPJyFtSuf7vdw1h+onygga6DWqg010sj+RfgrrKxlJCVvaedkEPdzyOYvrUG3H5hWOzC4xQGrMA== X-Received: by 2002:a17:902:8504:: with SMTP id bj4mr192134plb.231.1597860342514; Wed, 19 Aug 2020 11:05:42 -0700 (PDT) Received: from kaaira-HP-Pavilion-Notebook ([103.113.213.179]) by smtp.gmail.com with ESMTPSA id q2sm28843271pff.107.2020.08.19.11.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Aug 2020 11:05:42 -0700 (PDT) From: Kaaira Gupta To: Helen Koike , Shuah Khan , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Kieran Bingham Cc: Kaaira Gupta Subject: [PATCH v3 9/9] media: vimc: Run multiple captures on same thread Date: Wed, 19 Aug 2020 23:34:42 +0530 Message-Id: <20200819180442.11630-10-kgupta@es.iitr.ac.in> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819180442.11630-1-kgupta@es.iitr.ac.in> References: <20200819180442.11630-1-kgupta@es.iitr.ac.in> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If multiple captures try to enable stream, start their stream but do not initialise the pipeline again. Also, don't start the thread separately. Starting their streams will update the use count and their frames would be processed by the already running thread. Signed-off-by: Kaaira Gupta --- drivers/media/test-drivers/vimc/vimc-streamer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/test-drivers/vimc/vimc-streamer.c b/drivers/media/test-drivers/vimc/vimc-streamer.c index fade37bee26d..880c31759cc0 100644 --- a/drivers/media/test-drivers/vimc/vimc-streamer.c +++ b/drivers/media/test-drivers/vimc/vimc-streamer.c @@ -275,13 +275,14 @@ int vimc_streamer_s_stream(struct vimc_stream *stream, return ret; if (enable) { - if (stream->kthread) - return 0; ret = vimc_streamer_stream_start(ved); if (ret) goto out; + if (stream->kthread) + goto out; + ret = vimc_streamer_pipeline_init(stream, ved); if (ret) goto out;