Skip to contentSkip to conversation

media: video-i2c: add video-i2c driver support

PATCH Superseded Matt Ranostay 3 participants 6 messages Feb 27, 2018 – Mar 5, 2018

Subsystems (3)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Matt Ranostay

author maintainer
#0 lore raw

v4 cover media: video-i2c: add video-i2c driver support

Add support for video-i2c polling driver

Changes from v1:
* Switch to SPDX tags versus GPLv2 license text
* Remove unneeded zeroing of data structures
* Add video_i2c_try_fmt_vid_cap call in video_i2c_s_fmt_vid_cap function

Changes from v2:
* Add missing linux/kthread.h include that broke x86_64 build

Changes from v3:
* Add devicetree binding documents
* snprintf check added
* switched to per chip support based on devicetree or i2c client id
* add VB2_DMABUF to io_modes
* added entry to MAINTAINERS file switched to per chip support based on devicetree or i2c client id

Matt Ranostay (2):
media: dt-bindings: Add bindings for panasonic,amg88xx
media: video-i2c: add video-i2c driver

 .../bindings/media/i2c/panasonic,amg88xx.txt       |  19 +
 MAINTAINERS                                        |   6 +
 drivers/media/i2c/Kconfig                          |   9 +
 drivers/media/i2c/Makefile                         |   1 +
 drivers/media/i2c/video-i2c.c                      | 558 +++++++++++++++++++++
 5 files changed, 593 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/panasonic,amg88xx.txt
 create mode 100644 drivers/media/i2c/video-i2c.c
Signature · 1 line
2.14.1
author maintainer
#1 lore raw

PATCH v4 1/2 media: dt-bindings: Add bindings for panasonic,amg88xx

Define the device tree bindings for the panasonic,amg88xx i2c video driver.

---
 .../bindings/media/i2c/panasonic,amg88xx.txt          | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/panasonic,amg88xx.txt
Documentation/devicetree/bindings/media/i2c/panasonic,amg88xx.txt new file +19 -0
new file mode 100644
index 000000000000..4a3181a3dd7e
@@ -0,0 +1,19 @@
+* Panasonic AMG88xx
+
+The Panasonic family of AMG88xx Grid-Eye sensors allow recording
+8x8 10Hz video which consists of thermal datapoints
+
+Required Properties:
+ - compatible : Must be "panasonic,amg88xx"
+ - reg : i2c address of the device
+
+Example:
+
+	i2c0@1c22000 {
+		...
+		amg88xx@69 {
+			compatible = "panasonic,amg88xx";
+			reg = <0x69>;
+		};
+		...
+	};
Signature · 1 line
2.14.1
maintainer Reviewed-by on v4 1/2
#2 lore raw

Re: [PATCH v4 1/2] media: dt-bindings: Add bindings for panasonic,amg88xx

Quoted 10 lines · Matt Ranostay

Define the device tree bindings for the panasonic,amg88xx i2c video driver.

---
 .../bindings/media/i2c/panasonic,amg88xx.txt          | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/panasonic,amg88xx.txt
author maintainer
#3 lore raw

PATCH v4 2/2 media: video-i2c: add video-i2c driver

In reply to Matt Ranostay

There are several thermal sensors that only have a low-speed bus interface but output valid video data. This patchset enables support for the AMG88xx "Grid-Eye" sensor family.

Cc Luca Barbato <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 MAINTAINERS                   |   6 +
 drivers/media/i2c/Kconfig     |   9 +
 drivers/media/i2c/Makefile    |   1 +
 drivers/media/i2c/video-i2c.c | 558 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 574 insertions(+)
 create mode 100644 drivers/media/i2c/video-i2c.c
MAINTAINERS +6 -0
index 8c2320e1685c..90ae81ae0e09 100644
@@ -14776,6 +14776,12 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/media/platform/video-mux.c
 
+VIDEO I2C POLLING DRIVER
+M:	Matt Ranostay <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/media/i2c/video-i2c.c
+
 VIDEOBUF2 FRAMEWORK
 M:	Pawel Osciak <[email protected]>
 M:	Marek Szyprowski <[email protected]>
drivers/media/i2c/Kconfig +9 -0
index 8fdd673d449f..53aede720e0f 100644
@@ -917,6 +917,15 @@ config VIDEO_M52790
 
 	 To compile this driver as a module, choose M here: the
 	 module will be called m52790.
+
+config VIDEO_I2C
+	tristate "I2C transport video support"
+	depends on VIDEO_V4L2 && I2C
+	select VIDEOBUF2_VMALLOC
+	---help---
+	  Enable the I2C transport video support which supports the
+	  following:
+	   * Panasonic AMG88xx Grid-Eye Sensors
 endmenu
 
 menu "Sensors used on soc_camera driver"
drivers/media/i2c/Makefile +1 -0
index 26b19a2e9d04..5d4c06cb3f6f 100644
@@ -91,6 +91,7 @@ obj-$(CONFIG_VIDEO_LM3646)	+= lm3646.o
 obj-$(CONFIG_VIDEO_SMIAPP_PLL)	+= smiapp-pll.o
 obj-$(CONFIG_VIDEO_AK881X)		+= ak881x.o
 obj-$(CONFIG_VIDEO_IR_I2C)  += ir-kbd-i2c.o
+obj-$(CONFIG_VIDEO_I2C)		+= video-i2c.o
 obj-$(CONFIG_VIDEO_ML86V7667)	+= ml86v7667.o
 obj-$(CONFIG_VIDEO_OV2659)	+= ov2659.o
 obj-$(CONFIG_VIDEO_TC358743)	+= tc358743.o
drivers/media/i2c/video-i2c.c new file +558 -0

558 lines not on this page · raw message

Signature · 1 line
2.14.1
#4 lore raw

Re: [PATCH v4 2/2] media: video-i2c: add video-i2c driver

I love your patch! Perhaps something to improve:

Hi Matt,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.16-rc3 next-20180228]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Matt-Ranostay/media-video-i2c-add-video-i2c-driver-support/20180301-111038
base:   git://linuxtv.org/media_tree.git master
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64

All warnings (new ones prefixed by >>):

drivers/media//i2c/video-i2c.c: In function 'video_i2c_probe':

>> drivers/media//i2c/video-i2c.c:456:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
      chip_id = (int) of_device_get_match_data(&client->dev);
                ^

vim +456 drivers/media//i2c/video-i2c.c

442
443 static int video_i2c_probe(struct i2c_client *client,
444 const struct i2c_device_id *id)
445 {
446 struct video_i2c_data *data;
447 struct v4l2_device *v4l2_dev;
448 struct vb2_queue *queue;
449 int chip_id, ret;
450
451 data = kzalloc(sizeof(*data), GFP_KERNEL);
452 if (!data)
453 return -ENOMEM;
454
455 if (client->dev.of_node)

 > 456			chip_id = (int) of_device_get_match_data(&client->dev);

457 else
458 chip_id = id->driver_data;
459
460 data->chip = &video_i2c_chip[chip_id];
461 data->client = client;
462 v4l2_dev = &data->v4l2_dev;
463 strlcpy(v4l2_dev->name, VIDEO_I2C_DRIVER, sizeof(v4l2_dev->name));
464
465 ret = v4l2_device_register(&client->dev, v4l2_dev);
466 if (ret < 0)
467 goto error_free_device;
468
469 mutex_init(&data->lock);
470 mutex_init(&data->queue_lock);
471
472 queue = &data->vb_vidq;
473 queue->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
474 queue->io_modes = VB2_DMABUF | VB2_MMAP | VB2_USERPTR | VB2_READ;
475 queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
476 queue->drv_priv = data;
477 queue->buf_struct_size = sizeof(struct video_i2c_buffer);
478 queue->min_buffers_needed = 1;
479 queue->ops = &video_i2c_video_qops;
480 queue->mem_ops = &vb2_vmalloc_memops;
481
482 ret = vb2_queue_init(queue);
483 if (ret < 0)
484 goto error_unregister_device;
485
486 data->vdev.queue = queue;
487 data->vdev.queue->lock = &data->queue_lock;
488
489 snprintf(data->vdev.name, sizeof(data->vdev.name),
490 "I2C %d-%d Transport Video",
491 client->adapter->nr, client->addr);
492
493 data->vdev.v4l2_dev = v4l2_dev;
494 data->vdev.fops = &video_i2c_fops;
495 data->vdev.lock = &data->lock;
496 data->vdev.ioctl_ops = &video_i2c_ioctl_ops;
497 data->vdev.release = video_i2c_release;
498 data->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE |
499 V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
500
501 spin_lock_init(&data->slock);
502 INIT_LIST_HEAD(&data->vid_cap_active);
503
504 video_set_drvdata(&data->vdev, data);
505 i2c_set_clientdata(client, data);
506
507 ret = video_register_device(&data->vdev, VFL_TYPE_GRABBER, -1);
508 if (ret < 0)
509 goto error_unregister_device;
510
511 return 0;
512
513 error_unregister_device:
514 v4l2_device_unregister(v4l2_dev);
515
516 error_free_device:
517 kfree(data);
518
519 return ret;
520 }
521

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author maintainer
#5 lore raw

Re: [PATCH v4 2/2] media: video-i2c: add video-i2c driver

Quoted 18 lines · kbuild test robot

Hi Matt,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v4.16-rc3 next-20180228]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Matt-Ranostay/media-video-i2c-add-video-i2c-driver-support/20180301-111038
base:   git://linuxtv.org/media_tree.git master
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.2.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64

Quoted 5 lines

All warnings (new ones prefixed by >>):

drivers/media//i2c/video-i2c.c: In function 'video_i2c_probe':

Quoted 1 line
Quoted 1 line

drivers/media//i2c/video-i2c.c:456:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

      chip_id = (int) of_device_get_match_data(&client->dev);

Suspect this is some Itanium weirdness nobody cares about.

Quoted 88 lines
                ^

vim +456 drivers/media//i2c/video-i2c.c

   442
   443  static int video_i2c_probe(struct i2c_client *client,
   444                               const struct i2c_device_id *id)
   445  {
   446          struct video_i2c_data *data;
   447          struct v4l2_device *v4l2_dev;
   448          struct vb2_queue *queue;
   449          int chip_id, ret;
   450
   451          data = kzalloc(sizeof(*data), GFP_KERNEL);
   452          if (!data)
   453                  return -ENOMEM;
   454
   455          if (client->dev.of_node)
Quoted 1 line

456 chip_id = (int) of_device_get_match_data(&client->dev);

457 else

   458                  chip_id = id->driver_data;
   459
   460          data->chip = &video_i2c_chip[chip_id];
   461          data->client = client;
   462          v4l2_dev = &data->v4l2_dev;
   463          strlcpy(v4l2_dev->name, VIDEO_I2C_DRIVER, sizeof(v4l2_dev->name));
   464
   465          ret = v4l2_device_register(&client->dev, v4l2_dev);
   466          if (ret < 0)
   467                  goto error_free_device;
   468
   469          mutex_init(&data->lock);
   470          mutex_init(&data->queue_lock);
   471
   472          queue = &data->vb_vidq;
   473          queue->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
   474          queue->io_modes = VB2_DMABUF | VB2_MMAP | VB2_USERPTR | VB2_READ;
   475          queue->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
   476          queue->drv_priv = data;
   477          queue->buf_struct_size = sizeof(struct video_i2c_buffer);
   478          queue->min_buffers_needed = 1;
   479          queue->ops = &video_i2c_video_qops;
   480          queue->mem_ops = &vb2_vmalloc_memops;
   481
   482          ret = vb2_queue_init(queue);
   483          if (ret < 0)
   484                  goto error_unregister_device;
   485
   486          data->vdev.queue = queue;
   487          data->vdev.queue->lock = &data->queue_lock;
   488
   489          snprintf(data->vdev.name, sizeof(data->vdev.name),
   490                                   "I2C %d-%d Transport Video",
   491                                   client->adapter->nr, client->addr);
   492
   493          data->vdev.v4l2_dev = v4l2_dev;
   494          data->vdev.fops = &video_i2c_fops;
   495          data->vdev.lock = &data->lock;
   496          data->vdev.ioctl_ops = &video_i2c_ioctl_ops;
   497          data->vdev.release = video_i2c_release;
   498          data->vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE |
   499                                   V4L2_CAP_READWRITE | V4L2_CAP_STREAMING;
   500
   501          spin_lock_init(&data->slock);
   502          INIT_LIST_HEAD(&data->vid_cap_active);
   503
   504          video_set_drvdata(&data->vdev, data);
   505          i2c_set_clientdata(client, data);
   506
   507          ret = video_register_device(&data->vdev, VFL_TYPE_GRABBER, -1);
   508          if (ret < 0)
   509                  goto error_unregister_device;
   510
   511          return 0;
   512
   513  error_unregister_device:
   514          v4l2_device_unregister(v4l2_dev);
   515
   516  error_free_device:
   517          kfree(data);
   518
   519          return ret;
   520  }
   521

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation