From patchwork Thu Dec 29 22:27:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9491553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6CCE862AB7 for ; Thu, 29 Dec 2016 22:30:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5390020007 for ; Thu, 29 Dec 2016 22:30:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45B4725D99; Thu, 29 Dec 2016 22:30:25 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable 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 7473620007 for ; Thu, 29 Dec 2016 22:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751784AbcL2W3m (ORCPT ); Thu, 29 Dec 2016 17:29:42 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33680 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753445AbcL2W21 (ORCPT ); Thu, 29 Dec 2016 17:28:27 -0500 Received: by mail-pg0-f68.google.com with SMTP id g1so20092912pgn.0; Thu, 29 Dec 2016 14:28:27 -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:in-reply-to:references; bh=s7qsGJUvIU4T3TT7HYL/TdTqVXBPnDjWRwvR1FVzCuU=; b=RDrYbkbxGT+NCMkXC5bgQJ1fKqMpJ3eJle+70OtJsXlW+8NYluUgNXkb74OyI7sGA4 kYdonj8MUYcAkDHeFi2leD71Qv6tj6KHszZ5Y0PH58arpekQkeZUF3C2ErnO7XPd9VUV IR2Dc1++KtphlRj8Gp0Couab78fpg6zKup2OeuBjx/lmh9N6uQtphTDaByE2cNrIiGHk 4YCYxDtahP3eBaFKs+uJBjzCIdyNMNCHpH/E7pekCEERx9dlylWKkPbO6rMrRSbRhUdk jF7StvZeq5L7mesX3w78OCjNenWtLx0UPM+2UVzFXkcaD4BxkUeKdfCEnH9oxWnaDyMT alow== 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=s7qsGJUvIU4T3TT7HYL/TdTqVXBPnDjWRwvR1FVzCuU=; b=cdU0J1k+AnEU5j3KLpZ8A4ybXVsQNO+gjtfaV8ID0byKGcwJUfno89LLDqG9ssDbzK jz9UhP5pwz5JbJR3TLkJ0mUx92JQvM8wSG0H4D9BlYIENem0Pz/dX1sn/6J0DshjiVxx RVrmMksLie/wwVJovyT8A8XfUvOpJEZqk1SPSrcQOdMnrdnCJ34QBtva1Ffb6fNBVElL 2F2bgkktueHOGavmj61Hx9YU0J+KfdvmhGWih3pQkZMQFPbnTBXnsZxfX3CNcc2p8qBZ aoWnNIPzOaGve3QgkGfqdkdJzucihvJhqetAbDBWOY8nqs54KCVLYkEMtj9kElhqBmZu kV8w== X-Gm-Message-State: AIkVDXIJPqHc8WLV9XQRdb7/VIeIMf5HMxLCcVn8JQlxz5mYnKsXaS2dYbbyB0nO2ZMyjg== X-Received: by 10.98.102.18 with SMTP id a18mr36280429pfc.29.1483050500828; Thu, 29 Dec 2016 14:28:20 -0800 (PST) Received: from majic.sklembedded.com (c-73-241-2-21.hsd1.ca.comcast.net. [73.241.2.21]) by smtp.googlemail.com with ESMTPSA id u3sm107243068pfk.3.2016.12.29.14.28.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Dec 2016 14:28:19 -0800 (PST) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: shawnguo@kernel.org, kernel@pengutronix.de, fabio.estevam@nxp.com, robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, linus.walleij@linaro.org, gnurou@gmail.com, mchehab@kernel.org, gregkh@linuxfoundation.org, p.zabel@pengutronix.de Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-media@vger.kernel.org, devel@driverdev.osuosl.org, Steve Longerbeam Subject: [PATCH 14/20] media: imx: Add IC subdev drivers Date: Thu, 29 Dec 2016 14:27:29 -0800 Message-Id: <1483050455-10683-15-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483050455-10683-1-git-send-email-steve_longerbeam@mentor.com> References: <1483050455-10683-1-git-send-email-steve_longerbeam@mentor.com> 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 This is a set of three media entity subdevice drivers for the i.MX Image Converter. The i.MX IC module contains three independent "tasks": - Pre-processing Encode task: video frames are routed directly from the CSI and can be scaled, color-space converted, and rotated. Scaled output is limited to 1024x1024 resolution. Output frames can be routed to various sinks including the post-processing subdev task described below. - Pre-processing Viewfinder task: this task can perform the same conversions as the pre-process encode task, but in addition can be used for hardware motion compensated deinterlacing. Frames can come either directly from the CSIs or from memory via IDMAC channels. Scaled output is limited to 1024x1024 resolution. Output frames can be routed to various sinks including the post-processing subdev task. - Post-processing task: same conversions as pre-process encode. However this subdevice driver sends frames to the i.MX IPU image converter which supports image tiling, which allows scaled output up to 4096x4096 resolution. Output frames can be routed to the camera interface driver or a mem2mem driver. --- drivers/staging/media/imx/Makefile | 2 + drivers/staging/media/imx/imx-ic-common.c | 113 +++ drivers/staging/media/imx/imx-ic-pp.c | 636 ++++++++++++++++ drivers/staging/media/imx/imx-ic-prpenc.c | 1037 +++++++++++++++++++++++++ drivers/staging/media/imx/imx-ic-prpvf.c | 1181 +++++++++++++++++++++++++++++ drivers/staging/media/imx/imx-ic.h | 36 + 6 files changed, 3005 insertions(+) create mode 100644 drivers/staging/media/imx/imx-ic-common.c create mode 100644 drivers/staging/media/imx/imx-ic-pp.c create mode 100644 drivers/staging/media/imx/imx-ic-prpenc.c create mode 100644 drivers/staging/media/imx/imx-ic-prpvf.c create mode 100644 drivers/staging/media/imx/imx-ic.h diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index 3559d7b..d2a962c 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -1,8 +1,10 @@ imx-media-objs := imx-media-dev.o imx-media-fim.o imx-media-internal-sd.o \ imx-media-of.o +imx-ic-objs := imx-ic-common.o imx-ic-prpenc.o imx-ic-prpvf.o imx-ic-pp.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o +obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-ic.o obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-csi.o obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-smfc.o diff --git a/drivers/staging/media/imx/imx-ic-common.c b/drivers/staging/media/imx/imx-ic-common.c new file mode 100644 index 0000000..1b40558 --- /dev/null +++ b/drivers/staging/media/imx/imx-ic-common.c @@ -0,0 +1,113 @@ +/* + * V4L2 Image Converter Subdev for Freescale i.MX5/6 SOC + * + * Copyright (c) 2014-2016 Mentor Graphics Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include +#include +#include +#include +#include "imx-media.h" +#include "imx-ic.h" + +static struct imx_ic_ops *ic_ops[IC_NUM_TASKS] = { + [IC_TASK_ENCODER] = &imx_ic_prpenc_ops, + [IC_TASK_VIEWFINDER] = &imx_ic_prpvf_ops, + [IC_TASK_POST_PROCESSOR] = &imx_ic_pp_ops, +}; + +static int imx_ic_probe(struct platform_device *pdev) +{ + struct imx_media_internal_sd_platformdata *pdata; + struct imx_ic_priv *priv; + int ret; + + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + platform_set_drvdata(pdev, &priv->sd); + priv->dev = &pdev->dev; + + /* get our ipu_id, grp_id and IC task id */ + pdata = priv->dev->platform_data; + priv->ipu_id = pdata->ipu_id; + switch (pdata->grp_id) { + case IMX_MEDIA_GRP_ID_IC_PRPENC: + priv->task_id = IC_TASK_ENCODER; + break; + case IMX_MEDIA_GRP_ID_IC_PRPVF: + priv->task_id = IC_TASK_VIEWFINDER; + break; + case IMX_MEDIA_GRP_ID_IC_PP0...IMX_MEDIA_GRP_ID_IC_PP3: + priv->task_id = IC_TASK_POST_PROCESSOR; + break; + default: + return -EINVAL; + } + + v4l2_subdev_init(&priv->sd, ic_ops[priv->task_id]->subdev_ops); + v4l2_set_subdevdata(&priv->sd, priv); + priv->sd.internal_ops = ic_ops[priv->task_id]->internal_ops; + priv->sd.entity.ops = ic_ops[priv->task_id]->entity_ops; + priv->sd.entity.function = MEDIA_ENT_F_PROC_VIDEO_SCALER; + priv->sd.dev = &pdev->dev; + priv->sd.owner = THIS_MODULE; + priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; + priv->sd.grp_id = pdata->grp_id; + strncpy(priv->sd.name, pdata->sd_name, sizeof(priv->sd.name)); + + ret = ic_ops[priv->task_id]->init(priv); + if (ret) + return ret; + + ret = v4l2_async_register_subdev(&priv->sd); + if (ret) + goto remove; + + return 0; +remove: + ic_ops[priv->task_id]->remove(priv); + return ret; +} + +static int imx_ic_remove(struct platform_device *pdev) +{ + struct v4l2_subdev *sd = platform_get_drvdata(pdev); + struct imx_ic_priv *priv = container_of(sd, struct imx_ic_priv, sd); + + ic_ops[priv->task_id]->remove(priv); + + v4l2_async_unregister_subdev(&priv->sd); + media_entity_cleanup(&priv->sd.entity); + v4l2_device_unregister_subdev(sd); + + return 0; +} + +static const struct platform_device_id imx_ic_ids[] = { + { .name = "imx-ipuv3-ic" }, + { }, +}; +MODULE_DEVICE_TABLE(platform, imx_ic_ids); + +static struct platform_driver imx_ic_driver = { + .probe = imx_ic_probe, + .remove = imx_ic_remove, + .id_table = imx_ic_ids, + .driver = { + .name = "imx-ipuv3-ic", + .owner = THIS_MODULE, + }, +}; +module_platform_driver(imx_ic_driver); + +MODULE_DESCRIPTION("i.MX IC subdev driver"); +MODULE_AUTHOR("Steve Longerbeam "); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:imx-ipuv3-ic"); diff --git a/drivers/staging/media/imx/imx-ic-pp.c b/drivers/staging/media/imx/imx-ic-pp.c new file mode 100644 index 0000000..bc93696 --- /dev/null +++ b/drivers/staging/media/imx/imx-ic-pp.c @@ -0,0 +1,636 @@ +/* + * V4L2 IC Post-Processor Subdev for Freescale i.MX5/6 SOC + * + * Copyright (c) 2014-2016 Mentor Graphics Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include