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

2018-04-20 Thread Hans Verkuil
On 04/18/18 12:30, Sakari Ailus wrote:
> On Wed, Apr 18, 2018 at 01:46:08AM -0700, Matt Ranostay wrote:
> 
> ...
> 
>> On Wed, Apr 18, 2018 at 1:03 AM, Sakari Ailus  wrote:
 + if (vid_cap_buf) {
 + struct vb2_buffer *vb2_buf = 
 &vid_cap_buf->vb.vb2_buf;
 + void *vbuf = vb2_plane_vaddr(vb2_buf, 0);
 + int ret = data->chip->xfer(data, vbuf);
>>>
>>> As the assignment in variable declaration does more than just initialise a
>>> variable, it'd be nice to make the assignment separately from the variable
>>> declaration.
>>
>> Guessing you mean it is that initialization here is getting pushed and
>> popped off the stack if the data isn't in a register?
> 
> No, just that functionality is placed where variables are declared. The
> code is easier to read if you separate the two. I.e.
> 
> int ret;
> 
> ret = ...->xfer();

Matt, I'm making a pull request for this v8. I've split up this line myself,
so no need to post a v9.

Regards,

Hans

> 
>>
>>>
 +
 + vb2_buf->timestamp = ktime_get_ns();
 + vid_cap_buf->vb.sequence = data->sequence++;
 + vb2_buffer_done(vb2_buf, ret ?
 + VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
 + }
 +
 + schedule_delay = delay - (jiffies - start_jiffies);
 +
 + if (time_after(jiffies, start_jiffies + delay))
 + schedule_delay = delay;
 +
 + schedule_timeout_interruptible(schedule_delay);
 + } while (!kthread_should_stop());
 +
 + return 0;
 +}
> 



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

2018-04-18 Thread Sakari Ailus
On Wed, Apr 18, 2018 at 01:46:08AM -0700, Matt Ranostay wrote:

...

> On Wed, Apr 18, 2018 at 1:03 AM, Sakari Ailus  wrote:
> >> + if (vid_cap_buf) {
> >> + struct vb2_buffer *vb2_buf = 
> >> &vid_cap_buf->vb.vb2_buf;
> >> + void *vbuf = vb2_plane_vaddr(vb2_buf, 0);
> >> + int ret = data->chip->xfer(data, vbuf);
> >
> > As the assignment in variable declaration does more than just initialise a
> > variable, it'd be nice to make the assignment separately from the variable
> > declaration.
> 
> Guessing you mean it is that initialization here is getting pushed and
> popped off the stack if the data isn't in a register?

No, just that functionality is placed where variables are declared. The
code is easier to read if you separate the two. I.e.

int ret;

ret = ...->xfer();

> 
> >
> >> +
> >> + vb2_buf->timestamp = ktime_get_ns();
> >> + vid_cap_buf->vb.sequence = data->sequence++;
> >> + vb2_buffer_done(vb2_buf, ret ?
> >> + VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
> >> + }
> >> +
> >> + schedule_delay = delay - (jiffies - start_jiffies);
> >> +
> >> + if (time_after(jiffies, start_jiffies + delay))
> >> + schedule_delay = delay;
> >> +
> >> + schedule_timeout_interruptible(schedule_delay);
> >> + } while (!kthread_should_stop());
> >> +
> >> + return 0;
> >> +}

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi


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

2018-04-18 Thread Matt Ranostay
On Wed, Apr 18, 2018 at 1:03 AM, Sakari Ailus  wrote:
> Hi Matt,
>
> Thanks for the update.
>
> On Fri, Apr 06, 2018 at 03:52:31PM -0700, Matt Ranostay wrote:
>> 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.
>>
>> Signed-off-by: Matt Ranostay 
>> ---
>>  MAINTAINERS   |   6 +
>>  drivers/media/i2c/Kconfig |  13 +
>>  drivers/media/i2c/Makefile|   1 +
>>  drivers/media/i2c/video-i2c.c | 563 
>> ++
>>  4 files changed, 583 insertions(+)
>>  create mode 100644 drivers/media/i2c/video-i2c.c
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index dc153da22e8a..928b6a862626 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -14880,6 +14880,12 @@ L:   linux-media@vger.kernel.org
>>  S:   Maintained
>>  F:   drivers/media/platform/video-mux.c
>>
>> +VIDEO I2C POLLING DRIVER
>> +M:   Matt Ranostay 
>> +L:   linux-media@vger.kernel.org
>> +S:   Maintained
>> +F:   drivers/media/i2c/video-i2c.c
>> +
>>  VIDEOBUF2 FRAMEWORK
>>  M:   Pawel Osciak 
>>  M:   Marek Szyprowski 
>> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
>> index 541f0d28afd8..faaaceb94832 100644
>> --- a/drivers/media/i2c/Kconfig
>> +++ b/drivers/media/i2c/Kconfig
>> @@ -974,6 +974,19 @@ 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
>> +
>> +   To compile this driver as a module, choose M here: the
>> +   module will be called video-i2c
>> +
>>  endmenu
>>
>>  menu "Sensors used on soc_camera driver"
>> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
>> index ea34aee1a85a..84cc472238ef 100644
>> --- a/drivers/media/i2c/Makefile
>> +++ b/drivers/media/i2c/Makefile
>> @@ -96,6 +96,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
>> diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
>> new file mode 100644
>> index ..ec8a597597bf
>> --- /dev/null
>> +++ b/drivers/media/i2c/video-i2c.c
>> @@ -0,0 +1,563 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * video-i2c.c - Support for I2C transport video devices
>> + *
>> + * Copyright (C) 2018 Matt Ranostay 
>> + *
>> + * Supported:
>> + * - Panasonic AMG88xx Grid-Eye Sensors
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define VIDEO_I2C_DRIVER "video-i2c"
>> +
>> +struct video_i2c_chip;
>> +
>> +struct video_i2c_buffer {
>> + struct vb2_v4l2_buffer vb;
>> + struct list_head list;
>> +};
>> +
>> +struct video_i2c_data {
>> + struct i2c_client *client;
>> + const struct video_i2c_chip *chip;
>> + struct mutex lock;
>> + spinlock_t slock;
>> + unsigned int sequence;
>> + struct mutex queue_lock;
>> +
>> + struct v4l2_device v4l2_dev;
>> + struct video_device vdev;
>> + struct vb2_queue vb_vidq;
>> +
>> + struct task_struct *kthread_vid_cap;
>> + struct list_head vid_cap_active;
>> +};
>> +
>> +const static struct v4l2_fmtdesc amg88xx_format = {
>> + .pixelformat = V4L2_PIX_FMT_Y12,
>> +};
>> +
>> +const static struct v4l2_frmsize_discrete amg88xx_size = {
>> + .width = 8,
>> + .height = 8,
>> +};
>> +
>> +struct video_i2c_chip {
>> + /* video dimensions */
>> + const struct v4l2_fmtdesc *format;
>> + const struct v4l2_frmsize_discrete *size;
>> +
>> + /* max frames per second */
>> + unsigned int max_fps;
>> +
>> + /* pixel buffer size */
>> + unsigned int buffer_size;
>> +
>> + /* pixel size in bits */
>> + unsigned int bpp;
>> +
>> + /* xfer function */
>> + int (*xfer)(struct video_i2c_data *data, char *buf);
>> +};
>> +
>> +static int amg88xx_xfer(struct video_i2c_data *data, char *buf)
>> +{
>> + struct i2c_client *client = data->client;
>> + struct i2c_msg msg[2];
>> + u8 reg = 0x80;
>> + int ret;
>> +
>> + msg[0].addr = client->addr;
>> + msg[0].flags = 0;
>> + msg[0].len = 1;
>> + msg[0].buf  = (char *)®
>> +
>> +

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

2018-04-18 Thread Sakari Ailus
Hi Matt,

Thanks for the update.

On Fri, Apr 06, 2018 at 03:52:31PM -0700, Matt Ranostay wrote:
> 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.
> 
> Signed-off-by: Matt Ranostay 
> ---
>  MAINTAINERS   |   6 +
>  drivers/media/i2c/Kconfig |  13 +
>  drivers/media/i2c/Makefile|   1 +
>  drivers/media/i2c/video-i2c.c | 563 
> ++
>  4 files changed, 583 insertions(+)
>  create mode 100644 drivers/media/i2c/video-i2c.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index dc153da22e8a..928b6a862626 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -14880,6 +14880,12 @@ L:   linux-media@vger.kernel.org
>  S:   Maintained
>  F:   drivers/media/platform/video-mux.c
>  
> +VIDEO I2C POLLING DRIVER
> +M:   Matt Ranostay 
> +L:   linux-media@vger.kernel.org
> +S:   Maintained
> +F:   drivers/media/i2c/video-i2c.c
> +
>  VIDEOBUF2 FRAMEWORK
>  M:   Pawel Osciak 
>  M:   Marek Szyprowski 
> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> index 541f0d28afd8..faaaceb94832 100644
> --- a/drivers/media/i2c/Kconfig
> +++ b/drivers/media/i2c/Kconfig
> @@ -974,6 +974,19 @@ 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
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called video-i2c
> +
>  endmenu
>  
>  menu "Sensors used on soc_camera driver"
> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> index ea34aee1a85a..84cc472238ef 100644
> --- a/drivers/media/i2c/Makefile
> +++ b/drivers/media/i2c/Makefile
> @@ -96,6 +96,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
> diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
> new file mode 100644
> index ..ec8a597597bf
> --- /dev/null
> +++ b/drivers/media/i2c/video-i2c.c
> @@ -0,0 +1,563 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * video-i2c.c - Support for I2C transport video devices
> + *
> + * Copyright (C) 2018 Matt Ranostay 
> + *
> + * Supported:
> + * - Panasonic AMG88xx Grid-Eye Sensors
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define VIDEO_I2C_DRIVER "video-i2c"
> +
> +struct video_i2c_chip;
> +
> +struct video_i2c_buffer {
> + struct vb2_v4l2_buffer vb;
> + struct list_head list;
> +};
> +
> +struct video_i2c_data {
> + struct i2c_client *client;
> + const struct video_i2c_chip *chip;
> + struct mutex lock;
> + spinlock_t slock;
> + unsigned int sequence;
> + struct mutex queue_lock;
> +
> + struct v4l2_device v4l2_dev;
> + struct video_device vdev;
> + struct vb2_queue vb_vidq;
> +
> + struct task_struct *kthread_vid_cap;
> + struct list_head vid_cap_active;
> +};
> +
> +const static struct v4l2_fmtdesc amg88xx_format = {
> + .pixelformat = V4L2_PIX_FMT_Y12,
> +};
> +
> +const static struct v4l2_frmsize_discrete amg88xx_size = {
> + .width = 8,
> + .height = 8,
> +};
> +
> +struct video_i2c_chip {
> + /* video dimensions */
> + const struct v4l2_fmtdesc *format;
> + const struct v4l2_frmsize_discrete *size;
> +
> + /* max frames per second */
> + unsigned int max_fps;
> +
> + /* pixel buffer size */
> + unsigned int buffer_size;
> +
> + /* pixel size in bits */
> + unsigned int bpp;
> +
> + /* xfer function */
> + int (*xfer)(struct video_i2c_data *data, char *buf);
> +};
> +
> +static int amg88xx_xfer(struct video_i2c_data *data, char *buf)
> +{
> + struct i2c_client *client = data->client;
> + struct i2c_msg msg[2];
> + u8 reg = 0x80;
> + int ret;
> +
> + msg[0].addr = client->addr;
> + msg[0].flags = 0;
> + msg[0].len = 1;
> + msg[0].buf  = (char *)®
> +
> + msg[1].addr = client->addr;
> + msg[1].flags = I2C_M_RD;
> + msg[1].len = data->chip->buffer_size;
> + msg[1].buf = (char *)buf;
> +
> + ret = i2c_transfer(client->adapter, msg, 2);
> +
> + return (re

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

2018-04-18 Thread Matt Ranostay
Slight poke on this since the merge window craziness should be over
also I stupidly forgot to CC people who had comments in the last
revision. *grin*

- Matt

On Fri, Apr 6, 2018 at 3:52 PM, Matt Ranostay
 wrote:
> 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.
>
> Signed-off-by: Matt Ranostay 
> ---
>  MAINTAINERS   |   6 +
>  drivers/media/i2c/Kconfig |  13 +
>  drivers/media/i2c/Makefile|   1 +
>  drivers/media/i2c/video-i2c.c | 563 
> ++
>  4 files changed, 583 insertions(+)
>  create mode 100644 drivers/media/i2c/video-i2c.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index dc153da22e8a..928b6a862626 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -14880,6 +14880,12 @@ L: linux-media@vger.kernel.org
>  S: Maintained
>  F: drivers/media/platform/video-mux.c
>
> +VIDEO I2C POLLING DRIVER
> +M: Matt Ranostay 
> +L: linux-media@vger.kernel.org
> +S: Maintained
> +F: drivers/media/i2c/video-i2c.c
> +
>  VIDEOBUF2 FRAMEWORK
>  M: Pawel Osciak 
>  M: Marek Szyprowski 
> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> index 541f0d28afd8..faaaceb94832 100644
> --- a/drivers/media/i2c/Kconfig
> +++ b/drivers/media/i2c/Kconfig
> @@ -974,6 +974,19 @@ 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
> +
> + To compile this driver as a module, choose M here: the
> + module will be called video-i2c
> +
>  endmenu
>
>  menu "Sensors used on soc_camera driver"
> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> index ea34aee1a85a..84cc472238ef 100644
> --- a/drivers/media/i2c/Makefile
> +++ b/drivers/media/i2c/Makefile
> @@ -96,6 +96,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
> diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
> new file mode 100644
> index ..ec8a597597bf
> --- /dev/null
> +++ b/drivers/media/i2c/video-i2c.c
> @@ -0,0 +1,563 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * video-i2c.c - Support for I2C transport video devices
> + *
> + * Copyright (C) 2018 Matt Ranostay 
> + *
> + * Supported:
> + * - Panasonic AMG88xx Grid-Eye Sensors
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define VIDEO_I2C_DRIVER   "video-i2c"
> +
> +struct video_i2c_chip;
> +
> +struct video_i2c_buffer {
> +   struct vb2_v4l2_buffer vb;
> +   struct list_head list;
> +};
> +
> +struct video_i2c_data {
> +   struct i2c_client *client;
> +   const struct video_i2c_chip *chip;
> +   struct mutex lock;
> +   spinlock_t slock;
> +   unsigned int sequence;
> +   struct mutex queue_lock;
> +
> +   struct v4l2_device v4l2_dev;
> +   struct video_device vdev;
> +   struct vb2_queue vb_vidq;
> +
> +   struct task_struct *kthread_vid_cap;
> +   struct list_head vid_cap_active;
> +};
> +
> +const static struct v4l2_fmtdesc amg88xx_format = {
> +   .pixelformat = V4L2_PIX_FMT_Y12,
> +};
> +
> +const static struct v4l2_frmsize_discrete amg88xx_size = {
> +   .width = 8,
> +   .height = 8,
> +};
> +
> +struct video_i2c_chip {
> +   /* video dimensions */
> +   const struct v4l2_fmtdesc *format;
> +   const struct v4l2_frmsize_discrete *size;
> +
> +   /* max frames per second */
> +   unsigned int max_fps;
> +
> +   /* pixel buffer size */
> +   unsigned int buffer_size;
> +
> +   /* pixel size in bits */
> +   unsigned int bpp;
> +
> +   /* xfer function */
> +   int (*xfer)(struct video_i2c_data *data, char *buf);
> +};
> +
> +static int amg88xx_xfer(struct video_i2c_data *data, char *buf)
> +{
> +   struct i2c_client *client = data->client;
> +   struct i2c_msg msg[2];
> +   u8 reg = 0x80;
> +   int ret;
> +
> +   msg[0].addr = client->addr;
> +   msg[0].flags = 0;
> +   msg[0].len = 1;
> +   msg[0].buf  = (char *)®
> +
> +   

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

2018-04-06 Thread 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.

Signed-off-by: Matt Ranostay 
---
 MAINTAINERS   |   6 +
 drivers/media/i2c/Kconfig |  13 +
 drivers/media/i2c/Makefile|   1 +
 drivers/media/i2c/video-i2c.c | 563 ++
 4 files changed, 583 insertions(+)
 create mode 100644 drivers/media/i2c/video-i2c.c

diff --git a/MAINTAINERS b/MAINTAINERS
index dc153da22e8a..928b6a862626 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14880,6 +14880,12 @@ L: linux-media@vger.kernel.org
 S: Maintained
 F: drivers/media/platform/video-mux.c
 
+VIDEO I2C POLLING DRIVER
+M: Matt Ranostay 
+L: linux-media@vger.kernel.org
+S: Maintained
+F: drivers/media/i2c/video-i2c.c
+
 VIDEOBUF2 FRAMEWORK
 M: Pawel Osciak 
 M: Marek Szyprowski 
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 541f0d28afd8..faaaceb94832 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -974,6 +974,19 @@ 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
+
+ To compile this driver as a module, choose M here: the
+ module will be called video-i2c
+
 endmenu
 
 menu "Sensors used on soc_camera driver"
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index ea34aee1a85a..84cc472238ef 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -96,6 +96,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
diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c
new file mode 100644
index ..ec8a597597bf
--- /dev/null
+++ b/drivers/media/i2c/video-i2c.c
@@ -0,0 +1,563 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * video-i2c.c - Support for I2C transport video devices
+ *
+ * Copyright (C) 2018 Matt Ranostay 
+ *
+ * Supported:
+ * - Panasonic AMG88xx Grid-Eye Sensors
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define VIDEO_I2C_DRIVER   "video-i2c"
+
+struct video_i2c_chip;
+
+struct video_i2c_buffer {
+   struct vb2_v4l2_buffer vb;
+   struct list_head list;
+};
+
+struct video_i2c_data {
+   struct i2c_client *client;
+   const struct video_i2c_chip *chip;
+   struct mutex lock;
+   spinlock_t slock;
+   unsigned int sequence;
+   struct mutex queue_lock;
+
+   struct v4l2_device v4l2_dev;
+   struct video_device vdev;
+   struct vb2_queue vb_vidq;
+
+   struct task_struct *kthread_vid_cap;
+   struct list_head vid_cap_active;
+};
+
+const static struct v4l2_fmtdesc amg88xx_format = {
+   .pixelformat = V4L2_PIX_FMT_Y12,
+};
+
+const static struct v4l2_frmsize_discrete amg88xx_size = {
+   .width = 8,
+   .height = 8,
+};
+
+struct video_i2c_chip {
+   /* video dimensions */
+   const struct v4l2_fmtdesc *format;
+   const struct v4l2_frmsize_discrete *size;
+
+   /* max frames per second */
+   unsigned int max_fps;
+
+   /* pixel buffer size */
+   unsigned int buffer_size;
+
+   /* pixel size in bits */
+   unsigned int bpp;
+
+   /* xfer function */
+   int (*xfer)(struct video_i2c_data *data, char *buf);
+};
+
+static int amg88xx_xfer(struct video_i2c_data *data, char *buf)
+{
+   struct i2c_client *client = data->client;
+   struct i2c_msg msg[2];
+   u8 reg = 0x80;
+   int ret;
+
+   msg[0].addr = client->addr;
+   msg[0].flags = 0;
+   msg[0].len = 1;
+   msg[0].buf  = (char *)®
+
+   msg[1].addr = client->addr;
+   msg[1].flags = I2C_M_RD;
+   msg[1].len = data->chip->buffer_size;
+   msg[1].buf = (char *)buf;
+
+   ret = i2c_transfer(client->adapter, msg, 2);
+
+   return (ret == 2) ? 0 : -EIO;
+}
+
+#define AMG88XX0
+
+static const struct video_i2c_chip video_i2c_chip[] = {
+   [AMG88XX] = {
+   .size   = &amg88xx_size,
+   .format = &amg88xx_format,
+   .max_fps= 10,
+   .buffer_size= 128,
+