Skip to contentSkip to conversation

media: video-i2c: add video-i2c driver

PATCH Superseded Matt Ranostay 2 participants 2 messages Feb 16, 2018 – Feb 24, 2018

Subsystems (2)

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Matt Ranostay

author maintainer
#0 lore raw

PATCH v2 1/1 media: video-i2c: add video-i2c driver

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]>

---
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

 drivers/media/i2c/Kconfig     |   9 +
 drivers/media/i2c/Makefile    |   1 +
 drivers/media/i2c/video-i2c.c | 546 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 556 insertions(+)
 create mode 100644 drivers/media/i2c/video-i2c.c
drivers/media/i2c/Kconfig +9 -0
index 9f18cd296841..549f1e9fc01e 100644
@@ -908,6 +908,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 c0f94cd8d56d..5ca4c98a4bea 100644
@@ -90,6 +90,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 +546 -0

546 lines not on this page · raw message

Signature · 1 line
2.14.1
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi Matt,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v4.16-rc2 next-20180223]
[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/20180218-181041
base:   git://linuxtv.org/media_tree.git master
config: x86_64-randconfig-n0-02241505 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

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

>> drivers/media/i2c/video-i2c.c:205:12: error: implicit declaration of function 'kthread_should_stop'; did you mean 'freezer_should_skip'? [-Werror=implicit-function-declaration]
     } while (!kthread_should_stop());
               ^~~~~~~~~~~~~~~~~~~
               freezer_should_skip
   drivers/media/i2c/video-i2c.c: In function 'start_streaming':
>> drivers/media/i2c/video-i2c.c:218:26: error: implicit declaration of function 'kthread_run'; did you mean 'it_real_fn'? [-Werror=implicit-function-declaration]
     data->kthread_vid_cap = kthread_run(video_i2c_thread_vid_cap, data,
                             ^~~~~~~~~~~
                             it_real_fn
>> drivers/media/i2c/video-i2c.c:218:24: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     data->kthread_vid_cap = kthread_run(video_i2c_thread_vid_cap, data,
                           ^
   drivers/media/i2c/video-i2c.c: In function 'stop_streaming':
>> drivers/media/i2c/video-i2c.c:243:2: error: implicit declaration of function 'kthread_stop'; did you mean 'vb2_thread_stop'? [-Werror=implicit-function-declaration]
     kthread_stop(data->kthread_vid_cap);
     ^~~~~~~~~~~~
     vb2_thread_stop

cc1: some warnings being treated as errors

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

164
165 static int video_i2c_thread_vid_cap(void *priv)
166 {
167 struct video_i2c_data *data = priv;
168
169 set_freezable();
170
171 do {
172 unsigned long start_jiffies = jiffies;
173 unsigned int delay = msecs_to_jiffies(1000 / data->chip->max_fps);
174 struct video_i2c_buffer *vid_cap_buf = NULL;
175 int schedule_delay;
176
177 try_to_freeze();
178
179 spin_lock(&data->slock);
180
181 if (!list_empty(&data->vid_cap_active)) {
182 vid_cap_buf = list_entry(data->vid_cap_active.next,
183 struct video_i2c_buffer, list);
184 list_del(&vid_cap_buf->list);
185 }
186
187 spin_unlock(&data->slock);
188
189 if (vid_cap_buf) {
190 struct vb2_buffer *vb2_buf = &vid_cap_buf->vb.vb2_buf;
191 void *vbuf = vb2_plane_vaddr(vb2_buf, 0);
192 int ret = data->chip->xfer(data, vbuf);
193
194 vb2_buf->timestamp = ktime_get_ns();
195 vb2_buffer_done(vb2_buf, ret ?
196 VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);
197 }
198
199 schedule_delay = delay - (jiffies - start_jiffies);
200
201 if (time_after(jiffies, start_jiffies + delay))
202 schedule_delay = delay;
203
204 schedule_timeout_interruptible(schedule_delay);

 > 205		} while (!kthread_should_stop());
   206	
   207		return 0;
   208	}
   209	
   210	static int start_streaming(struct vb2_queue *vq, unsigned int count)
   211	{
   212		struct video_i2c_data *data = vb2_get_drv_priv(vq);
   213		struct video_i2c_buffer *buf, *tmp;
   214	
   215		if (data->kthread_vid_cap)
   216			return 0;
   217	
 > 218		data->kthread_vid_cap = kthread_run(video_i2c_thread_vid_cap, data,
   219						    "%s-vid-cap", data->v4l2_dev.name);
   220		if (!IS_ERR(data->kthread_vid_cap))
   221			return 0;
   222	
   223		spin_lock(&data->slock);
   224	
   225		list_for_each_entry_safe(buf, tmp, &data->vid_cap_active, list) {
   226			list_del(&buf->list);
   227			vb2_buffer_done(&buf->vb.vb2_buf,
   228					VB2_BUF_STATE_QUEUED);
   229		}
   230	
   231		spin_unlock(&data->slock);
   232	
   233		return PTR_ERR(data->kthread_vid_cap);
   234	}
   235	
   236	static void stop_streaming(struct vb2_queue *vq)
   237	{
   238		struct video_i2c_data *data = vb2_get_drv_priv(vq);
   239	
   240		if (data->kthread_vid_cap == NULL)
   241			return;
   242	
 > 243		kthread_stop(data->kthread_vid_cap);

244
245 spin_lock(&data->slock);
246
247 while (!list_empty(&data->vid_cap_active)) {
248 struct video_i2c_buffer *buf;
249
250 buf = list_entry(data->vid_cap_active.next,
251 struct video_i2c_buffer, list);
252 list_del(&buf->list);
253 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
254 }
255 spin_unlock(&data->slock);
256
257 data->kthread_vid_cap = NULL;
258 }
259

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