Re: [PATCH v2 12/19] media: imx: Add SMFC subdev driver
On 01/04/2017 06:23 AM, Vladimir Zapolskiy wrote: On 01/03/2017 10:57 PM, Steve Longerbeam wrote: This is a media entity subdevice driver for the i.MX Sensor Multi-FIFO Controller module. Video frames are received from the CSI and can be routed to various sinks including the i.MX Image Converter for scaling, color-space conversion, motion compensated deinterlacing, and image rotation. Signed-off-by: Steve Longerbeam--- drivers/staging/media/imx/Makefile | 1 + drivers/staging/media/imx/imx-smfc.c | 739 +++ 2 files changed, 740 insertions(+) create mode 100644 drivers/staging/media/imx/imx-smfc.c diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index 133672a..3559d7b 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -5,4 +5,5 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-csi.o +obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-smfc.o May be obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-csi.o imx-smfc.o I'd prefer to keep them on separate lines, to indicate they are all built as separate modules. diff --git a/drivers/staging/media/imx/imx-smfc.c b/drivers/staging/media/imx/imx-smfc.c new file mode 100644 index 000..565048c --- /dev/null +++ b/drivers/staging/media/imx/imx-smfc.c @@ -0,0 +1,739 @@ +/* + * V4L2 Capture SMFC Subdev for Freescale i.MX5/6 SOC + * + * This subdevice handles capture of raw/unconverted video frames + * from the CSI, directly to memory via the Sensor Multi-FIFO Controller. + * + * Copyright (c) 2012-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 Please sort the list of headers alphabetically. done. +static irqreturn_t imx_smfc_eof_interrupt(int irq, void *dev_id) +{ + struct imx_smfc_priv *priv = dev_id; + struct imx_media_dma_buf *done, *next; + unsigned long flags; + + spin_lock_irqsave(>irqlock, flags); spin_lock(>irqlock) should be sufficient. yes thanks. + +static const struct platform_device_id imx_smfc_ids[] = { + { .name = "imx-ipuv3-smfc" }, + { }, +}; +MODULE_DEVICE_TABLE(platform, imx_smfc_ids); + +static struct platform_driver imx_smfc_driver = { + .probe = imx_smfc_probe, + .remove = imx_smfc_remove, + .id_table = imx_smfc_ids, + .driver = { + .name = "imx-ipuv3-smfc", + .owner = THIS_MODULE, You can drop owner assignment. done. Steve -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 12/19] media: imx: Add SMFC subdev driver
On 01/03/2017 10:57 PM, Steve Longerbeam wrote: > This is a media entity subdevice driver for the i.MX Sensor Multi-FIFO > Controller module. Video frames are received from the CSI and can > be routed to various sinks including the i.MX Image Converter for > scaling, color-space conversion, motion compensated deinterlacing, > and image rotation. > > Signed-off-by: Steve Longerbeam> --- > drivers/staging/media/imx/Makefile | 1 + > drivers/staging/media/imx/imx-smfc.c | 739 > +++ > 2 files changed, 740 insertions(+) > create mode 100644 drivers/staging/media/imx/imx-smfc.c > > diff --git a/drivers/staging/media/imx/Makefile > b/drivers/staging/media/imx/Makefile > index 133672a..3559d7b 100644 > --- a/drivers/staging/media/imx/Makefile > +++ b/drivers/staging/media/imx/Makefile > @@ -5,4 +5,5 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o > obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.o > > obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-csi.o > +obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-smfc.o May be obj-$(CONFIG_VIDEO_IMX_CAMERA) += imx-csi.o imx-smfc.o > > diff --git a/drivers/staging/media/imx/imx-smfc.c > b/drivers/staging/media/imx/imx-smfc.c > new file mode 100644 > index 000..565048c > --- /dev/null > +++ b/drivers/staging/media/imx/imx-smfc.c > @@ -0,0 +1,739 @@ > +/* > + * V4L2 Capture SMFC Subdev for Freescale i.MX5/6 SOC > + * > + * This subdevice handles capture of raw/unconverted video frames > + * from the CSI, directly to memory via the Sensor Multi-FIFO Controller. > + * > + * Copyright (c) 2012-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 Please sort the list of headers alphabetically. > +#include > +#include "imx-media.h" > + [snip] > +static irqreturn_t imx_smfc_eof_interrupt(int irq, void *dev_id) > +{ > + struct imx_smfc_priv *priv = dev_id; > + struct imx_media_dma_buf *done, *next; > + unsigned long flags; > + > + spin_lock_irqsave(>irqlock, flags); spin_lock(>irqlock) should be sufficient. > + > + if (priv->last_eof) { > + complete(>last_eof_comp); > + priv->last_eof = false; > + goto unlock; > + } > + > + /* inform CSI of this EOF so it can monitor frame intervals */ > + v4l2_subdev_call(priv->src_sd, core, interrupt_service_routine, > + 0, NULL); > + > + done = imx_media_dma_buf_get_active(priv->out_ring); > + /* give the completed buffer to the sink */ > + if (!WARN_ON(!done)) > + imx_media_dma_buf_done(done, IMX_MEDIA_BUF_STATUS_DONE); > + > + /* priv->next buffer is now the active one */ > + imx_media_dma_buf_set_active(priv->next); > + > + /* bump the EOF timeout timer */ > + mod_timer(>eof_timeout_timer, > + jiffies + msecs_to_jiffies(IMX_MEDIA_EOF_TIMEOUT)); > + > + if (ipu_idmac_buffer_is_ready(priv->smfc_ch, priv->ipu_buf_num)) > + ipu_idmac_clear_buffer(priv->smfc_ch, priv->ipu_buf_num); > + > + /* get next queued buffer */ > + next = imx_media_dma_buf_get_next_queued(priv->out_ring); > + > + ipu_cpmem_set_buffer(priv->smfc_ch, priv->ipu_buf_num, next->phys); > + ipu_idmac_select_buffer(priv->smfc_ch, priv->ipu_buf_num); > + > + /* toggle IPU double-buffer index */ > + priv->ipu_buf_num ^= 1; > + priv->next = next; > + > +unlock: > + spin_unlock_irqrestore(>irqlock, flags); > + return IRQ_HANDLED; > +} > + [snip] > + > +static const struct platform_device_id imx_smfc_ids[] = { > + { .name = "imx-ipuv3-smfc" }, > + { }, > +}; > +MODULE_DEVICE_TABLE(platform, imx_smfc_ids); > + > +static struct platform_driver imx_smfc_driver = { > + .probe = imx_smfc_probe, > + .remove = imx_smfc_remove, > + .id_table = imx_smfc_ids, > + .driver = { > + .name = "imx-ipuv3-smfc", > + .owner = THIS_MODULE, You can drop owner assignment. > + }, > +}; > +module_platform_driver(imx_smfc_driver); > + > +MODULE_DESCRIPTION("i.MX SMFC subdev driver"); > +MODULE_AUTHOR("Steve Longerbeam "); > +MODULE_LICENSE("GPL"); > +MODULE_ALIAS("platform:imx-ipuv3-smfc"); > -- With best wishes, Vladimir -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 12/19] media: imx: Add SMFC subdev driver
This is a media entity subdevice driver for the i.MX Sensor Multi-FIFO Controller module. Video frames are received from the CSI and can be routed to various sinks including the i.MX Image Converter for scaling, color-space conversion, motion compensated deinterlacing, and image rotation. Signed-off-by: Steve Longerbeam--- drivers/staging/media/imx/Makefile | 1 + drivers/staging/media/imx/imx-smfc.c | 739 +++ 2 files changed, 740 insertions(+) create mode 100644 drivers/staging/media/imx/imx-smfc.c diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index 133672a..3559d7b 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -5,4 +5,5 @@ obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media.o obj-$(CONFIG_VIDEO_IMX_MEDIA) += imx-media-common.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-smfc.c b/drivers/staging/media/imx/imx-smfc.c new file mode 100644 index 000..565048c --- /dev/null +++ b/drivers/staging/media/imx/imx-smfc.c @@ -0,0 +1,739 @@ +/* + * V4L2 Capture SMFC Subdev for Freescale i.MX5/6 SOC + * + * This subdevice handles capture of raw/unconverted video frames + * from the CSI, directly to memory via the Sensor Multi-FIFO Controller. + * + * Copyright (c) 2012-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 +#include "imx-media.h" + +/* + * Min/Max supported width and heights. + * + * We allow planar output from the SMFC, so we have to align + * output width by 16 pixels to meet IDMAC alignment requirements, + * which also means input width must have the same alignment. + */ +#define MIN_W 176 +#define MIN_H 144 +#define MAX_W 8192 +#define MAX_H 4096 +#define W_ALIGN4 /* multiple of 16 pixels */ +#define H_ALIGN1 /* multiple of 2 lines */ +#define S_ALIGN1 /* multiple of 2 */ + +#define SMFC_NUM_PADS 2 + +struct imx_smfc_priv { + struct device*dev; + struct ipu_soc *ipu; + struct imx_media_dev *md; + struct v4l2_subdev sd; + struct media_pad pad[SMFC_NUM_PADS]; + int ipu_id; + int smfc_id; + int input_pad; + int output_pad; + + struct ipuv3_channel *smfc_ch; + struct ipu_smfc *smfc; + + struct v4l2_mbus_framefmt format_mbus[SMFC_NUM_PADS]; + const struct imx_media_pixfmt *cc[SMFC_NUM_PADS]; + + struct v4l2_mbus_config sensor_mbus_cfg; + + /* the dma buffer ring to send to sink */ + struct imx_media_dma_buf_ring *out_ring; + struct imx_media_dma_buf *next; + + int ipu_buf_num; /* ipu double buffer index: 0-1 */ + + /* the sink that will receive the dma buffers */ + struct v4l2_subdev *sink_sd; + struct v4l2_subdev *src_sd; + + /* +* the CSI id and mipi virtual channel number at +* link validate +*/ + int csi_id; + int vc_num; + + /* the attached sensor at stream on */ + struct imx_media_subdev *sensor; + + spinlock_t irqlock; + struct timer_list eof_timeout_timer; + int eof_irq; + int nfb4eof_irq; + + bool stream_on; /* streaming is on */ + bool last_eof; /* waiting for last EOF at stream off */ + struct completion last_eof_comp; +}; + +static void imx_smfc_put_ipu_resources(struct imx_smfc_priv *priv) +{ + if (!IS_ERR_OR_NULL(priv->smfc_ch)) + ipu_idmac_put(priv->smfc_ch); + priv->smfc_ch = NULL; + + if (!IS_ERR_OR_NULL(priv->smfc)) + ipu_smfc_put(priv->smfc); + priv->smfc = NULL; +} + +static int imx_smfc_get_ipu_resources(struct imx_smfc_priv *priv) +{ + int ch_num, ret; + + priv->ipu = priv->md->ipu[priv->ipu_id]; + + ch_num = IPUV3_CHANNEL_CSI0 + priv->smfc_id; + + priv->smfc = ipu_smfc_get(priv->ipu, ch_num); + if (IS_ERR(priv->smfc)) { + v4l2_err(>sd, "failed to get SMFC\n"); + ret = PTR_ERR(priv->smfc); + goto out; + } + + priv->smfc_ch = ipu_idmac_get(priv->ipu, ch_num); + if (IS_ERR(priv->smfc_ch)) { + v4l2_err(>sd, "could not get IDMAC channel %u\n", ch_num); + ret = PTR_ERR(priv->smfc_ch); + goto out; + } + + return 0; +out: + imx_smfc_put_ipu_resources(priv); + return ret; +} + +static irqreturn_t imx_smfc_eof_interrupt(int irq, void *dev_id) +{ +