From patchwork Mon May 7 16:21:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 135105 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp3355802lji; Mon, 7 May 2018 09:22:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZobbF5L09hCWKmJd4l8XBj9lHbGlxqxMwzmhEwKFTBt/IcG+XU2GqCm0WZXvAPbTBmpG6K/ X-Received: by 2002:a24:1a85:: with SMTP id 127-v6mr1891277iti.143.1525710149800; Mon, 07 May 2018 09:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525710149; cv=none; d=google.com; s=arc-20160816; b=INzVYGdlZlfZS14qgUH5/1y89/NK8U5FMndq2YtZ91iW2L5KpNpvxHl1sFw88js/6B DWscTRIaF2H/RGxJpRpH8LPT+gYiLMvyeJsrXcPuAd3dEyfFLaTNS/o395XJiNQB/GSX PydLSNjMUclcnZIPtjgZrjF6uhofAfA0lJYPO5NM7SQBloZM+KyM3ogAVReGb4sM0Iec 2Z3FAIn60d6CnWzPmGFHKstMy2nWDq6pu0MzkCGZ03HtVzswuTmmZ96Cbaacjtr4mZqb +/gJilXlAdssej52wvdWdXFEdZBRFLcwozxHka2b+Q1uiUpvhcLVvXXiUkkSAN7AK2eN /5Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=OPXP9CjIaTppi52Y+mfUlfyomGGMDQHb6SO2kATzGAw=; b=UFHni22bRt4DyIBDvGWd53r+8wixG+hiXl7hSuq61aaWaXu3V04behtUf/qBvQPf1u 8Isz0kTRmcmscsDLdJZsCG2aBvmhP+LKu1ApbTSYtDcxUZm+r2QpOYACrk+XEHP99tAr 8XiTVwBVGkKqFqsUPcJkfT92MOH5t8myk4TCI2cqcdO18H8tNuIPkn1qFwqxd7l90Zex NwTcRuAkz24GwY10uYFyW3KUKffmkBkx6afOomX6s44mlyTXRDXjWf7PoI6RvDEwuMBq TWwtHqNsVCmjJLyDQIgPF61DfGmFl1SH4o0IW9Wa6yjrjMXbjzDRaVsXpFvsHhmklBvQ loeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VX7ThvLL; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k124-v6si7484127ith.131.2018.05.07.09.22.29; Mon, 07 May 2018 09:22:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VX7ThvLL; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752223AbeEGQW2 (ORCPT + 5 others); Mon, 7 May 2018 12:22:28 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35856 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752035AbeEGQW1 (ORCPT ); Mon, 7 May 2018 12:22:27 -0400 Received: by mail-wm0-f65.google.com with SMTP id n10-v6so16407684wmc.1 for ; Mon, 07 May 2018 09:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OPXP9CjIaTppi52Y+mfUlfyomGGMDQHb6SO2kATzGAw=; b=VX7ThvLLIFacKwtqgsXSCDb25KMKHhO4/fTA/0o5ZeBTjfgESxAWZgyzQkyM2pJzHR kCZ2E4cDSMtSVjewaUcVsuw9l31488CGVtjcC2iQQIW+1Dby3Ko9BP+8OlmlLezLTJOu 4Bn48k2nxqUn1ObMgwblFzxtWc62POIXA+OFs= 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=OPXP9CjIaTppi52Y+mfUlfyomGGMDQHb6SO2kATzGAw=; b=FryVwv279qAtkAVtq7BBDUSh03zhoceXIv/06MFyzCtD4+LLsoZAPtIff4AqcaE5xb qAOwusXUeJz/jxh84spKz6PuptdIgPv9cOvIs+QcNPmuMCFGB9ATWDXsXrj523wPPmaP AEZXyZ0G2ybyY+7+yI/NrSoE//AvkKqlqtXRFrVhG8WKSwxCtr00hocdmRhq9F7et5IE giZD31iJJZxakFczkY3WgBO1SX3oT77Ia/S8KVmkEaA5K6H3glL04YLbxtHdIp/TLzp9 1zxyVWpEJ0C5VvZ3DbvhR53EYn7T4G3Jj2cv/S8gUHxhsmbebqFhr9BW6g1U1ibxPder Zvvw== X-Gm-Message-State: ALKqPwfgLHD6b2jsaB0S+U+EeNO723WyDyB575dEQN8LAkSDDptN6Kb0 Dsnh9lAfCtIUl3ShcSWjUKY9VQ== X-Received: by 2002:a1c:8583:: with SMTP id h125-v6mr1164986wmd.98.1525710146506; Mon, 07 May 2018 09:22:26 -0700 (PDT) Received: from arch-late.local (a109-49-46-234.cpe.netcabo.pt. [109.49.46.234]) by smtp.gmail.com with ESMTPSA id b11-v6sm26410251wrf.50.2018.05.07.09.22.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 09:22:25 -0700 (PDT) From: Rui Miguel Silva To: mchehab@kernel.org, sakari.ailus@linux.intel.com, Steve Longerbeam , Philipp Zabel , Rob Herring Cc: linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Shawn Guo , Fabio Estevam , devicetree@vger.kernel.org, Greg Kroah-Hartman , Ryan Harkin , Rui Miguel Silva Subject: [PATCH v3 01/14] media: staging/imx: add support to media dev for no IPU systems Date: Mon, 7 May 2018 17:21:39 +0100 Message-Id: <20180507162152.2545-2-rui.silva@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180507162152.2545-1-rui.silva@linaro.org> References: <20180507162152.2545-1-rui.silva@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Some i.MX SoC do not have IPU, like the i.MX7, add to the the media device infrastructure support to be used in this type of systems that do not have internal subdevices besides the CSI. Signed-off-by: Rui Miguel Silva --- drivers/staging/media/imx/imx-media-dev.c | 38 ++++++++++++++++--- .../staging/media/imx/imx-media-internal-sd.c | 3 ++ drivers/staging/media/imx/imx-media.h | 3 ++ 3 files changed, 39 insertions(+), 5 deletions(-) -- 2.17.0 diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c index f67ec8e27093..b019dcefccd6 100644 --- a/drivers/staging/media/imx/imx-media-dev.c +++ b/drivers/staging/media/imx/imx-media-dev.c @@ -27,6 +27,12 @@ #include #include "imx-media.h" +static const struct of_device_id imx_media_dt_ids[]; + +struct imx_media_driver_data { + bool ipu_present; +}; + static inline struct imx_media_dev *notifier2dev(struct v4l2_async_notifier *n) { return container_of(n, struct imx_media_dev, notifier); @@ -92,6 +98,9 @@ static int imx_media_get_ipu(struct imx_media_dev *imxmd, struct ipu_soc *ipu; int ipu_id; + if (!imxmd->ipu_present) + return 0; + ipu = dev_get_drvdata(csi_sd->dev->parent); if (!ipu) { v4l2_err(&imxmd->v4l2_dev, @@ -440,6 +449,8 @@ static const struct media_device_ops imx_media_md_ops = { static int imx_media_probe(struct platform_device *pdev) { + const struct imx_media_driver_data *drvdata; + const struct of_device_id *of_id; struct device *dev = &pdev->dev; struct device_node *node = dev->of_node; struct imx_media_dev *imxmd; @@ -481,16 +492,29 @@ static int imx_media_probe(struct platform_device *pdev) goto notifier_cleanup; } - ret = imx_media_add_internal_subdevs(imxmd); - if (ret) { - v4l2_err(&imxmd->v4l2_dev, - "add_internal_subdevs failed with %d\n", ret); + of_id = of_match_device(imx_media_dt_ids, &pdev->dev); + if (!of_id) { + v4l2_err(&imxmd->v4l2_dev, "failed to find driver data\n"); goto notifier_cleanup; } + drvdata = of_id->data; + + imxmd->ipu_present = drvdata->ipu_present; + + if (imxmd->ipu_present) { + ret = imx_media_add_internal_subdevs(imxmd); + if (ret) { + v4l2_err(&imxmd->v4l2_dev, + "add_internal_subdevs failed with %d\n", ret); + goto notifier_cleanup; + } + } + /* no subdevs? just bail */ if (imxmd->notifier.num_subdevs == 0) { ret = -ENODEV; + v4l2_err(&imxmd->v4l2_dev, "no subdevs\n"); goto notifier_cleanup; } @@ -533,8 +557,12 @@ static int imx_media_remove(struct platform_device *pdev) return 0; } +static const struct imx_media_driver_data imx6_drvdata = { + .ipu_present = true, +}; + static const struct of_device_id imx_media_dt_ids[] = { - { .compatible = "fsl,imx-capture-subsystem" }, + { .compatible = "fsl,imx-capture-subsystem", .data = &imx6_drvdata }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, imx_media_dt_ids); diff --git a/drivers/staging/media/imx/imx-media-internal-sd.c b/drivers/staging/media/imx/imx-media-internal-sd.c index 0fdc45dbfb76..2bcdc232369a 100644 --- a/drivers/staging/media/imx/imx-media-internal-sd.c +++ b/drivers/staging/media/imx/imx-media-internal-sd.c @@ -238,6 +238,9 @@ int imx_media_create_internal_links(struct imx_media_dev *imxmd, struct media_pad *pad; int i, j, ret; + if (!imxmd->ipu_present) + return 0; + intsd = find_intsd_by_grp_id(sd->grp_id); if (!intsd) return -ENODEV; diff --git a/drivers/staging/media/imx/imx-media.h b/drivers/staging/media/imx/imx-media.h index 44532cd5b812..d40538ecf176 100644 --- a/drivers/staging/media/imx/imx-media.h +++ b/drivers/staging/media/imx/imx-media.h @@ -147,6 +147,9 @@ struct imx_media_dev { /* for async subdev registration */ struct v4l2_async_notifier notifier; + + /* indicator to if the system has IPU */ + bool ipu_present; }; enum codespace_sel {