Re: [EXT] Re: [PATCH v9 6/8] media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder

2021-03-11 Thread Mirela Rabulea
On Thu, 2021-03-11 at 08:27 +0100, Hans Verkuil wrote:
> Caution: EXT Email
> 
> Hi Mirela,
> 
> On 11/03/2021 01:28, Mirela Rabulea (OSS) wrote:
> 
> 
> 
> > +static const struct of_device_id mxc_jpeg_match[] = {
> > + {
> > + .compatible = "nxp,imx8qxp-jpgdec",
> > + .data   = (void *)MXC_JPEG_DECODE,
> 
> Don't do this, just say:
> 
> static const int mxc_decode_mode = MXC_JPEG_DECODE;
> static const int mxc_encode_mode = MXC_JPEG_ENCODE;
> 
> and point to that:
> 
> .data = _decode_mode;
> 
> > + },
> > + {
> > + .compatible = "nxp,imx8qxp-jpgenc",
> > + .data   = (void *)MXC_JPEG_ENCODE,
> 
> .data = _encode_mode;
> 
> > + },
> > + { },
> > +};
> 
> 
> 
> > +static int mxc_jpeg_probe(struct platform_device *pdev)
> > +{
> > + struct mxc_jpeg_dev *jpeg;
> > + struct device *dev = >dev;
> > + struct resource *res;
> > + int dec_irq;
> > + int ret;
> > + int mode;
> > + const struct of_device_id *of_id;
> > + unsigned int slot;
> > +
> > + of_id = of_match_node(mxc_jpeg_match, dev->of_node);
> > + mode = (int)(u64)of_id->data;
> 
> and this becomes:
> 
> mode = *(const int *)of_id->data;
> 
> This will solve the kernel test robot warning, and for that matter
> the same gcc warnings I get when I compile.

Hi Hans,
thanks for the suggestion, I missed that warning among the verbosity
from the other ones. Perhaps for the future it would be usefull for me
to try and replicate the kernel test robot environment.
 
I sent v9.1 just for this patch.

Regards,
Mirela

> 
> Just post a v9.1 for this patch, everything else looks good.
> 
> Regards,
> 
> Hans


Re: [PATCH v9 6/8] media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder

2021-03-10 Thread Hans Verkuil
Hi Mirela,

On 11/03/2021 01:28, Mirela Rabulea (OSS) wrote:



> +static const struct of_device_id mxc_jpeg_match[] = {
> + {
> + .compatible = "nxp,imx8qxp-jpgdec",
> + .data   = (void *)MXC_JPEG_DECODE,

Don't do this, just say:

static const int mxc_decode_mode = MXC_JPEG_DECODE;
static const int mxc_encode_mode = MXC_JPEG_ENCODE;

and point to that:

.data = _decode_mode;

> + },
> + {
> + .compatible = "nxp,imx8qxp-jpgenc",
> + .data   = (void *)MXC_JPEG_ENCODE,

.data = _encode_mode;

> + },
> + { },
> +};



> +static int mxc_jpeg_probe(struct platform_device *pdev)
> +{
> + struct mxc_jpeg_dev *jpeg;
> + struct device *dev = >dev;
> + struct resource *res;
> + int dec_irq;
> + int ret;
> + int mode;
> + const struct of_device_id *of_id;
> + unsigned int slot;
> +
> + of_id = of_match_node(mxc_jpeg_match, dev->of_node);
> + mode = (int)(u64)of_id->data;

and this becomes:

mode = *(const int *)of_id->data;

This will solve the kernel test robot warning, and for that matter
the same gcc warnings I get when I compile.

Just post a v9.1 for this patch, everything else looks good.

Regards,

Hans


Re: [PATCH v9 6/8] media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder

2021-03-10 Thread kernel test robot
Hi "Mirela,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on shawnguo/for-next robh/for-next linus/master 
v5.12-rc2 next-20210310]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Mirela-Rabulea-OSS/Add-V4L2-driver-for-i-MX8-JPEG-Encoder-Decoder/20210311-083324
base:   git://linuxtv.org/media_tree.git master
config: microblaze-randconfig-r021-20210308 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/0day-ci/linux/commit/c6db61a15ca1a173f200f4a2344b3198652d64a6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Mirela-Rabulea-OSS/Add-V4L2-driver-for-i-MX8-JPEG-Encoder-Decoder/20210311-083324
git checkout c6db61a15ca1a173f200f4a2344b3198652d64a6
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross 
ARCH=microblaze 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

   drivers/media/platform/imx-jpeg/mxc-jpeg.c: In function 'mxc_jpeg_probe':
>> drivers/media/platform/imx-jpeg/mxc-jpeg.c:1967:14: warning: cast from 
>> pointer to integer of different size [-Wpointer-to-int-cast]
1967 |  mode = (int)(u64)of_id->data;
 |  ^


vim +1967 drivers/media/platform/imx-jpeg/mxc-jpeg.c

  1954  
  1955  static int mxc_jpeg_probe(struct platform_device *pdev)
  1956  {
  1957  struct mxc_jpeg_dev *jpeg;
  1958  struct device *dev = >dev;
  1959  struct resource *res;
  1960  int dec_irq;
  1961  int ret;
  1962  int mode;
  1963  const struct of_device_id *of_id;
  1964  unsigned int slot;
  1965  
  1966  of_id = of_match_node(mxc_jpeg_match, dev->of_node);
> 1967  mode = (int)(u64)of_id->data;
  1968  
  1969  jpeg = devm_kzalloc(dev, sizeof(struct mxc_jpeg_dev), 
GFP_KERNEL);
  1970  if (!jpeg)
  1971  return -ENOMEM;
  1972  
  1973  mutex_init(>lock);
  1974  spin_lock_init(>hw_lock);
  1975  
  1976  ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
  1977  if (ret) {
  1978  dev_err(>dev, "No suitable DMA available.\n");
  1979  goto err_irq;
  1980  }
  1981  
  1982  res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1983  jpeg->base_reg = devm_ioremap_resource(>dev, res);
  1984  if (IS_ERR(jpeg->base_reg))
  1985  return PTR_ERR(jpeg->base_reg);
  1986  
  1987  for (slot = 0; slot < MXC_MAX_SLOTS; slot++) {
  1988  dec_irq = platform_get_irq(pdev, slot);
  1989  if (dec_irq < 0) {
  1990  dev_err(>dev, "Failed to get irq %d\n", 
dec_irq);
  1991  ret = dec_irq;
  1992  goto err_irq;
  1993  }
  1994  ret = devm_request_irq(>dev, dec_irq, 
mxc_jpeg_dec_irq,
  1995 0, pdev->name, jpeg);
  1996  if (ret) {
  1997  dev_err(>dev, "Failed to request irq %d 
(%d)\n",
  1998  dec_irq, ret);
  1999  goto err_irq;
  2000  }
  2001  }
  2002  
  2003  jpeg->pdev = pdev;
  2004  jpeg->dev = dev;
  2005  jpeg->mode = mode;
  2006  
  2007  ret = mxc_jpeg_attach_pm_domains(jpeg);
  2008  if (ret < 0) {
  2009  dev_err(dev, "failed to attach power domains %d\n", 
ret);
  2010  return ret;
  2011  }
  2012  
  2013  /* v4l2 */
  2014  ret = v4l2_device_register(dev, >v4l2_dev);
  2015  if (ret) {
  2016  dev_err(dev, "failed to register v4l2 device\n");
  2017  goto err_register;
  2018  }
  2019  jpeg->m2m_dev = v4l2_m2m_init(_jpeg_m2m_ops);
  2020  if (IS_ERR(jpeg->m2m_dev)) {
  2021  dev_err(dev, "failed to register v4l2 device\n");
  2022  goto err_m2m;
  2023  }
  2024  
  2025  jpeg->dec_vdev = video_device_alloc();
  2026  if (!jpeg->dec_vdev) {
  2027  dev_err(dev, "failed to register v4l2 device\n");
  2028  goto err_vdev_alloc;
  2029  }
  2030  if (mode == MXC_JPEG_ENCODE)
  2031  

[PATCH v9 6/8] media: imx-jpeg: Add V4L2 driver for i.MX8 JPEG Encoder/Decoder

2021-03-10 Thread Mirela Rabulea (OSS)
From: Mirela Rabulea 

V4L2 driver for the JPEG encoder/decoder from i.MX8QXP/i.MX8QM application
processors.
The multi-planar buffers API is used.

Baseline and extended sequential jpeg decoding is supported.
Progressive jpeg decoding is not supported by the IP.
Supports encode and decode of various formats:
 YUV444, YUV422, YUV420, RGB, ARGB, Gray
YUV420 is the only multi-planar format supported.
Minimum resolution is 64 x 64, maximum 8192 x 8192.
The alignment requirements for the resolution depend on the format,
multiple of 16 resolutions should work for all formats.

v4l2-compliance tests are passing, including the
streaming tests, "v4l2-compliance -s"

Signed-off-by: Mirela Rabulea 
---
Changes in v9:
  Added comment to clearly state this driver will only support full-range 
quantization for YUV
  Squash the jpeg helper patch (former patch 9) into this one
  Simplified 2 dev_dbg's, to avoid kernel test robot warning:
dma_addr_t type is ong long unsigned int for arm64, versus unsigned int for 
powerpc64
which is used by kernel test robot)

I have received feedback on this patch over time from:
Hans Verkuil, Philipp Zabel, Laurentiu Palcu, Ezequiel Garcia
Thanks everyone for taking the time to review.

I got one explicit Reviewed-by from Philipp, for the jpeg helpers integration, 
from former patch 9 which was squashed here.

Full change log here:

Changes in v8:
  Fixes after feedback from Hans:
-Use v4l2_disable_ioctl() to disable the VIDIOC_(TRY)_ENCODER_CMD ioctls
for the decoder and the VIDIOC_(TRY)_DECODER_CMD ioctls for the encoder,
and drop the checks from mxc_jpeg_decoder_cmd/mxc_jpeg_encoder_cmd
-Fix mxc_jpeg_queue_setup for CREATE_BUFS situation,
return 0 to avoid overwriting sizes array.
-Fold release_active_buffers into mxc_jpeg_stop_streaming, 
fix it so it does not touch internal vb2_queue data structures,
use vim2m_stop_streaming as model.
-Always set V4L2_FIELD_NONE in mxc_jpeg_buf_out_validate
-Rename decoder -> codec in mxc_jpeg_querycap,
since this driver is used for both encoder and decoder.
-Drop buffer index out of range check from mxc_jpeg_qbuf,
since it is done inside vb2_queue_or_prepare_buf.
In fact, drop mxc_jpeg_qbuf alltogether, just use v4l2_m2m_ioctl_qbuf.
-Move the setting of V4L2_FIELD_NONE from to mxc_jpeg_dqbuf
to mxc_jpeg_buf_prepare()
-Replace mxc_jpeg_try_decoder_cmd with v4l2_m2m_ioctl_try_decoder_cmd
Also replace mxc_jpeg_try_encoder_cmd with v4l2_m2m_ioctl_try_encoder_cmd

Changes in v7:
  Add print_mxc_buf() to replace print_buf_preview() and print_nbuf_to_eoi(),
  and inside, use the print_hex_dump() from printk.h, also, print all the 
planes.

Changes in v5:
  Fixes after feedback from Laurentiu, Hans:
  Properly indented data blocks for encoder configuration stream
one tab to the right.
  Remove fourcc_to_str, instead just print the format directly (%c%c%c%c)
  Use the "debug" module parameter instead of "mxc_jpeg_tracing".
  Change return type for get_byte function (end of jpeg stream was not properly 
detected, visible only with corrupted stream)
  Use NULL instead of 0 for NULL pointers.
  Add a check to exit jpeg parse if stream does not start with SOI (slow run on 
v4l2-compliance streaming tests otherwise, the same problem was fixed in jpeg 
helpers)
  Change compatible name to match patch 3
  Fix colorspace information to sRGB for both output & capture (latest 
v4l2-compliance fail)
  Squashed patch 7 (v4l2-compliance streaming test fix for decoder)

Changes in v4:
  The main change is using the common jpeg helpers in imx-jpeg (feedback from 
Ezequiel)
  Patch 7 - new, fixed a problem with v4l2-compliance streaming tests on decoder
  small update: VFL_TYPE_VIDEO-> VFL_TYPE_GRABBER and 2 typos

Changes in v2:
  Fix v4l2-compliance streaming tests, "v4l2-compliance -s"

  Fixup some whitespaces in mxc_jpeg_ioctl_ops.
  Fixed one inconsistent indentation reported by kernel test robot

 drivers/media/platform/Kconfig|2 +
 drivers/media/platform/Makefile   |1 +
 drivers/media/platform/imx-jpeg/Kconfig   |   11 +
 drivers/media/platform/imx-jpeg/Makefile  |3 +
 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.c |  168 ++
 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.h |  140 ++
 drivers/media/platform/imx-jpeg/mxc-jpeg.c| 2122 +
 drivers/media/platform/imx-jpeg/mxc-jpeg.h|  180 ++
 8 files changed, 2627 insertions(+)
 create mode 100644 drivers/media/platform/imx-jpeg/Kconfig
 create mode 100644 drivers/media/platform/imx-jpeg/Makefile
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.c
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg-hw.h
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg.c
 create mode 100644 drivers/media/platform/imx-jpeg/mxc-jpeg.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 1ddb5d6354cf..ac07db1a5104 100644
--- a/drivers/media/platform/Kconfig