From patchwork Fri Sep 6 11:55:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 11135087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE84E1395 for ; Fri, 6 Sep 2019 11:56:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8C709214DE for ; Fri, 6 Sep 2019 11:56:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sZ6/Rkoe"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XGaztWcz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C709214DE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KI42uVwodeshuxdtqArSkF6AKO4FPqySPEUjFjoXOlQ=; b=sZ6/RkoezJ0bJG /B0nnwk1yIWpk1N9GhNSX6tx7ILT3hEby4fauXtqwLwSX976nIAA94Yuvxjl5Z3VkVwwpsG9UUf8K rM9q5ZD6eYJcIS2UO6ub59fqAwwyhecagkJ1b3YXVaQhklKjl39YUq92WiOzf4X8wEBc6uzwe4V2h v7Q9X413hjhKchdKZlGkxvIMBH/GJfKMZqoeguldBng6VE978peOornoqlXSfwTi5gCrwyVvgvxEs e/Ec9x4BpTTitjaElW9LxVlifE84sXlrijY7V93/lWcA4zH38tmB/tIiTsz1huVj+6OvxdOZ7gVKr cc6Fg2IfTc9et7/ze87Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i6CqV-0004Kh-6Z; Fri, 06 Sep 2019 11:56:07 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i6CqR-0004HJ-UO for linux-mediatek@lists.infradead.org; Fri, 06 Sep 2019 11:56:05 +0000 Received: by mail-pf1-x441.google.com with SMTP id b13so4294533pfo.8 for ; Fri, 06 Sep 2019 04:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JZfqsyf6E7qNi8d0uHMTslvkHYYxxoFC9pGOwYz59rY=; b=XGaztWczFM3DFRBteEZsy9iz0HHDTzLO9EuZEMK7P2xlI7Bu6t70z3JG24Tgdq7uoz cUCFb/oFjuxJ7qglU6stIyJXZMAKb155d3NROd3zd1eFcn34BkCcuFrLyexyahy08cVa ThuVnxwqArG1xsmPE9Znn6BObgbDtcT3nBjRs= 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=JZfqsyf6E7qNi8d0uHMTslvkHYYxxoFC9pGOwYz59rY=; b=FFeBtmNNw55C6gZgVCsWoPtGeli/iBE+oxuABKR7UF43KY/CWji2CPqsOXXhCGqo5A RYtRkU8QCLJXkWAwHWmpx571QB+5UTO6dbpNV9qv0AwL1fjqMts6yzugpz3hZ5tqBScW 1T1rMTKiHJ/ffnsecXMcgeLm7l5eE/1NDDhmEfgdH3o4Yofs29+bf466EZ9tkB/aSabh 1M88xBg+ZrfXu4xvK2gP9k3cmvRLLm3E/Z1SyLyRrQk53o9EL3gkVcDcdPaf+mgkR/LZ BjsQP6lIo8ZMIdY3et+K3Y877adkoCVDqtvAC9IIYWP0Wxzo4cKzWtQu0r9TDv/EC/dL IkVQ== X-Gm-Message-State: APjAAAUmqfM2IEYE43OKl7+qtKXC2dwxtX95wCNdeLTx5atHLLpDZl3k 88mPseu01iEiJqFpY3L6TPSMlA== X-Google-Smtp-Source: APXvYqyFf/aKYMAyWuUvsAqpMruHGhO70SSlVo+6UyVWGn7jSKN1LsO2oh6GiQ1ZPjkjjlrH+oPfng== X-Received: by 2002:a62:c102:: with SMTP id i2mr10414642pfg.7.1567770963594; Fri, 06 Sep 2019 04:56:03 -0700 (PDT) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:4:9712:8cf1:d0f:7d33]) by smtp.gmail.com with ESMTPSA id o22sm3667394pjq.21.2019.09.06.04.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 04:56:03 -0700 (PDT) From: Alexandre Courbot To: Yunfei Dong , Tiffany Lin , Andrew-CT Chen , Hans Verkuil , Mauro Carvalho Chehab Subject: [RFC PATCH v2 12/13] media: mtk-vcodec: vdec: add media device if using stateless api Date: Fri, 6 Sep 2019 20:55:12 +0900 Message-Id: <20190906115513.159705-13-acourbot@chromium.org> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog In-Reply-To: <20190906115513.159705-1-acourbot@chromium.org> References: <20190906115513.159705-1-acourbot@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190906_045603_987929_85D2A680 X-CRM114-Status: GOOD ( 12.47 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:441 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandre Courbot , linux-media@vger.kernel.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org From: Yunfei Dong The stateless API requires a media device for issuing requests. Add one if it turns out we are using it. Signed-off-by: Yunfei Dong [acourbot: refactor, cleanup and split] Co-developed-by: Alexandre Courbot Signed-off-by: Alexandre Courbot --- drivers/media/platform/Kconfig | 1 + .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 40 +++++++++++++++++++ .../platform/mtk-vcodec/mtk_vcodec_drv.h | 2 + 3 files changed, 43 insertions(+) diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index 83a785010753..86e97e5c3c10 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -248,6 +248,7 @@ config VIDEO_MEDIATEK_VCODEC select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV select VIDEO_MEDIATEK_VPU + select MEDIA_CONTROLLER help Mediatek video codec driver provides HW capability to encode and decode in a range of video formats diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index 53a9e016d989..7b4afac18297 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "mtk_vcodec_drv.h" #include "mtk_vcodec_dec.h" @@ -329,6 +330,31 @@ static int mtk_vcodec_probe(struct platform_device *pdev) goto err_event_workq; } + if (dev->vdec_pdata->uses_stateless_api) { + dev->mdev_dec.dev = &pdev->dev; + strscpy(dev->mdev_dec.model, MTK_VCODEC_DEC_NAME, + sizeof(dev->mdev_dec.model)); + + media_device_init(&dev->mdev_dec); + dev->mdev_dec.ops = &mtk_vcodec_media_ops; + dev->v4l2_dev.mdev = &dev->mdev_dec; + + ret = v4l2_m2m_register_media_controller(dev->m2m_dev_dec, + dev->vfd_dec, MEDIA_ENT_F_PROC_VIDEO_DECODER); + if (ret) { + mtk_v4l2_err("Failed to register media controller"); + goto err_reg_cont; + } + + ret = media_device_register(&dev->mdev_dec); + if (ret) { + mtk_v4l2_err("Failed to register media device"); + goto err_media_reg; + } + + mtk_v4l2_debug(0, "media registered as /dev/media%d", + vfd_dec->num); + } ret = video_register_device(vfd_dec, VFL_TYPE_GRABBER, 0); if (ret) { mtk_v4l2_err("Failed to register video device"); @@ -341,6 +367,12 @@ static int mtk_vcodec_probe(struct platform_device *pdev) return 0; err_dec_reg: + if (dev->vdec_pdata->uses_stateless_api) + media_device_unregister(&dev->mdev_dec); +err_media_reg: + if (dev->vdec_pdata->uses_stateless_api) + v4l2_m2m_unregister_media_controller(dev->m2m_dev_dec); +err_reg_cont: destroy_workqueue(dev->decode_workqueue); err_event_workq: v4l2_m2m_release(dev->m2m_dev_dec); @@ -354,6 +386,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev) } extern const struct mtk_vcodec_dec_pdata mtk_frame_8173_pdata; +extern const struct mtk_vcodec_dec_pdata mtk_req_8183_pdata; static const struct of_device_id mtk_vcodec_match[] = { { @@ -371,6 +404,13 @@ static int mtk_vcodec_dec_remove(struct platform_device *pdev) flush_workqueue(dev->decode_workqueue); destroy_workqueue(dev->decode_workqueue); + + if (media_devnode_is_registered(dev->mdev_dec.devnode)) { + media_device_unregister(&dev->mdev_dec); + v4l2_m2m_unregister_media_controller(dev->m2m_dev_dec); + media_device_cleanup(&dev->mdev_dec); + } + if (dev->m2m_dev_dec) v4l2_m2m_release(dev->m2m_dev_dec); diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h index 8167eeaa40e4..2202e8de9631 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h @@ -355,6 +355,7 @@ struct mtk_vcodec_dec_pdata { * struct mtk_vcodec_dev - driver data * @v4l2_dev: V4L2 device to register video devices for. * @vfd_dec: Video device for decoder + * @mdev_dec: Media device for decoder * @vfd_enc: Video device for encoder. * * @m2m_dev_dec: m2m device for decoder @@ -391,6 +392,7 @@ struct mtk_vcodec_dec_pdata { struct mtk_vcodec_dev { struct v4l2_device v4l2_dev; struct video_device *vfd_dec; + struct media_device mdev_dec; struct video_device *vfd_enc; struct v4l2_m2m_dev *m2m_dev_dec;