blob: 93961a1e694f231ee4044ef416cd5775b2b78cf9 [file] [log] [blame]
Helen Koikef2fe8902017-04-07 14:55:19 -03001/*
2 * vimc-sensor.c Virtual Media Controller Driver
3 *
4 * Copyright (C) 2015-2017 Helen Koike <helen.fornazier@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 */
17
Helen Fornazier4a29b702017-06-19 14:00:18 -030018#include <linux/component.h>
Helen Fornazier4a29b702017-06-19 14:00:18 -030019#include <linux/module.h>
Randy Dunlapac316722018-06-19 22:47:28 -070020#include <linux/mod_devicetable.h>
Helen Fornazier4a29b702017-06-19 14:00:18 -030021#include <linux/platform_device.h>
Helen Koikef2fe8902017-04-07 14:55:19 -030022#include <linux/v4l2-mediabus.h>
23#include <linux/vmalloc.h>
Hans Verkuil52cf1d92017-11-06 05:20:01 -050024#include <media/v4l2-ctrls.h>
Hans Verkuil3da7ee92018-02-02 08:00:32 -050025#include <media/v4l2-event.h>
Helen Koikef2fe8902017-04-07 14:55:19 -030026#include <media/v4l2-subdev.h>
Mauro Carvalho Chehab1beb6232017-10-09 06:02:25 -040027#include <media/tpg/v4l2-tpg.h>
Helen Koikef2fe8902017-04-07 14:55:19 -030028
Helen Fornazier4a29b702017-06-19 14:00:18 -030029#include "vimc-common.h"
30
31#define VIMC_SEN_DRV_NAME "vimc-sensor"
Helen Koikef2fe8902017-04-07 14:55:19 -030032
33struct vimc_sen_device {
34 struct vimc_ent_device ved;
35 struct v4l2_subdev sd;
Helen Fornazier4a29b702017-06-19 14:00:18 -030036 struct device *dev;
Helen Fornazier554946c2017-06-19 14:00:10 -030037 struct tpg_data tpg;
Helen Koikef2fe8902017-04-07 14:55:19 -030038 struct task_struct *kthread_sen;
39 u8 *frame;
40 /* The active format */
41 struct v4l2_mbus_framefmt mbus_format;
Hans Verkuil52cf1d92017-11-06 05:20:01 -050042 struct v4l2_ctrl_handler hdl;
Helen Koikef2fe8902017-04-07 14:55:19 -030043};
44
Helen Fornazier88ad71a2017-06-19 14:00:16 -030045static const struct v4l2_mbus_framefmt fmt_default = {
46 .width = 640,
47 .height = 480,
48 .code = MEDIA_BUS_FMT_RGB888_1X24,
49 .field = V4L2_FIELD_NONE,
50 .colorspace = V4L2_COLORSPACE_DEFAULT,
51};
52
53static int vimc_sen_init_cfg(struct v4l2_subdev *sd,
54 struct v4l2_subdev_pad_config *cfg)
55{
56 unsigned int i;
57
58 for (i = 0; i < sd->entity.num_pads; i++) {
59 struct v4l2_mbus_framefmt *mf;
60
61 mf = v4l2_subdev_get_try_format(sd, cfg, i);
62 *mf = fmt_default;
63 }
64
65 return 0;
66}
67
Helen Koikef2fe8902017-04-07 14:55:19 -030068static int vimc_sen_enum_mbus_code(struct v4l2_subdev *sd,
69 struct v4l2_subdev_pad_config *cfg,
70 struct v4l2_subdev_mbus_code_enum *code)
71{
Helen Fornazier88ad71a2017-06-19 14:00:16 -030072 const struct vimc_pix_map *vpix = vimc_pix_map_by_index(code->index);
Helen Koikef2fe8902017-04-07 14:55:19 -030073
Helen Fornazier88ad71a2017-06-19 14:00:16 -030074 if (!vpix)
Helen Koikef2fe8902017-04-07 14:55:19 -030075 return -EINVAL;
76
Helen Fornazier88ad71a2017-06-19 14:00:16 -030077 code->code = vpix->code;
Helen Koikef2fe8902017-04-07 14:55:19 -030078
79 return 0;
80}
81
82static int vimc_sen_enum_frame_size(struct v4l2_subdev *sd,
83 struct v4l2_subdev_pad_config *cfg,
84 struct v4l2_subdev_frame_size_enum *fse)
85{
Helen Fornazier88ad71a2017-06-19 14:00:16 -030086 const struct vimc_pix_map *vpix;
Helen Koikef2fe8902017-04-07 14:55:19 -030087
Helen Koikef2fe8902017-04-07 14:55:19 -030088 if (fse->index)
89 return -EINVAL;
90
Helen Fornazier88ad71a2017-06-19 14:00:16 -030091 /* Only accept code in the pix map table */
92 vpix = vimc_pix_map_by_code(fse->code);
93 if (!vpix)
Helen Koikef2fe8902017-04-07 14:55:19 -030094 return -EINVAL;
95
Helen Fornazier88ad71a2017-06-19 14:00:16 -030096 fse->min_width = VIMC_FRAME_MIN_WIDTH;
97 fse->max_width = VIMC_FRAME_MAX_WIDTH;
98 fse->min_height = VIMC_FRAME_MIN_HEIGHT;
99 fse->max_height = VIMC_FRAME_MAX_HEIGHT;
Helen Koikef2fe8902017-04-07 14:55:19 -0300100
101 return 0;
102}
103
104static int vimc_sen_get_fmt(struct v4l2_subdev *sd,
105 struct v4l2_subdev_pad_config *cfg,
Helen Fornazier88ad71a2017-06-19 14:00:16 -0300106 struct v4l2_subdev_format *fmt)
Helen Koikef2fe8902017-04-07 14:55:19 -0300107{
108 struct vimc_sen_device *vsen =
109 container_of(sd, struct vimc_sen_device, sd);
110
Helen Fornazier88ad71a2017-06-19 14:00:16 -0300111 fmt->format = fmt->which == V4L2_SUBDEV_FORMAT_TRY ?
112 *v4l2_subdev_get_try_format(sd, cfg, fmt->pad) :
113 vsen->mbus_format;
Helen Koikef2fe8902017-04-07 14:55:19 -0300114
115 return 0;
116}
117
Helen Fornazier554946c2017-06-19 14:00:10 -0300118static void vimc_sen_tpg_s_format(struct vimc_sen_device *vsen)
119{
120 const struct vimc_pix_map *vpix =
121 vimc_pix_map_by_code(vsen->mbus_format.code);
122
123 tpg_reset_source(&vsen->tpg, vsen->mbus_format.width,
124 vsen->mbus_format.height, vsen->mbus_format.field);
125 tpg_s_bytesperline(&vsen->tpg, 0, vsen->mbus_format.width * vpix->bpp);
126 tpg_s_buf_height(&vsen->tpg, vsen->mbus_format.height);
127 tpg_s_fourcc(&vsen->tpg, vpix->pixelformat);
128 /* TODO: add support for V4L2_FIELD_ALTERNATE */
129 tpg_s_field(&vsen->tpg, vsen->mbus_format.field, false);
130 tpg_s_colorspace(&vsen->tpg, vsen->mbus_format.colorspace);
131 tpg_s_ycbcr_enc(&vsen->tpg, vsen->mbus_format.ycbcr_enc);
132 tpg_s_quantization(&vsen->tpg, vsen->mbus_format.quantization);
133 tpg_s_xfer_func(&vsen->tpg, vsen->mbus_format.xfer_func);
134}
135
Helen Fornazier88ad71a2017-06-19 14:00:16 -0300136static void vimc_sen_adjust_fmt(struct v4l2_mbus_framefmt *fmt)
137{
138 const struct vimc_pix_map *vpix;
139
140 /* Only accept code in the pix map table */
141 vpix = vimc_pix_map_by_code(fmt->code);
142 if (!vpix)
143 fmt->code = fmt_default.code;
144
145 fmt->width = clamp_t(u32, fmt->width, VIMC_FRAME_MIN_WIDTH,
146 VIMC_FRAME_MAX_WIDTH) & ~1;
147 fmt->height = clamp_t(u32, fmt->height, VIMC_FRAME_MIN_HEIGHT,
148 VIMC_FRAME_MAX_HEIGHT) & ~1;
149
150 /* TODO: add support for V4L2_FIELD_ALTERNATE */
151 if (fmt->field == V4L2_FIELD_ANY || fmt->field == V4L2_FIELD_ALTERNATE)
152 fmt->field = fmt_default.field;
153
154 vimc_colorimetry_clamp(fmt);
155}
156
157static int vimc_sen_set_fmt(struct v4l2_subdev *sd,
158 struct v4l2_subdev_pad_config *cfg,
159 struct v4l2_subdev_format *fmt)
160{
161 struct vimc_sen_device *vsen = v4l2_get_subdevdata(sd);
162 struct v4l2_mbus_framefmt *mf;
163
164 if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
165 /* Do not change the format while stream is on */
166 if (vsen->frame)
167 return -EBUSY;
168
169 mf = &vsen->mbus_format;
170 } else {
171 mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
172 }
173
174 /* Set the new format */
175 vimc_sen_adjust_fmt(&fmt->format);
176
Helen Fornazier4a29b702017-06-19 14:00:18 -0300177 dev_dbg(vsen->dev, "%s: format update: "
Helen Fornazier88ad71a2017-06-19 14:00:16 -0300178 "old:%dx%d (0x%x, %d, %d, %d, %d) "
179 "new:%dx%d (0x%x, %d, %d, %d, %d)\n", vsen->sd.name,
180 /* old */
181 mf->width, mf->height, mf->code,
182 mf->colorspace, mf->quantization,
183 mf->xfer_func, mf->ycbcr_enc,
184 /* new */
185 fmt->format.width, fmt->format.height, fmt->format.code,
186 fmt->format.colorspace, fmt->format.quantization,
187 fmt->format.xfer_func, fmt->format.ycbcr_enc);
188
189 *mf = fmt->format;
190
191 return 0;
192}
193
Helen Koikef2fe8902017-04-07 14:55:19 -0300194static const struct v4l2_subdev_pad_ops vimc_sen_pad_ops = {
Helen Fornazier88ad71a2017-06-19 14:00:16 -0300195 .init_cfg = vimc_sen_init_cfg,
Helen Koikef2fe8902017-04-07 14:55:19 -0300196 .enum_mbus_code = vimc_sen_enum_mbus_code,
197 .enum_frame_size = vimc_sen_enum_frame_size,
198 .get_fmt = vimc_sen_get_fmt,
Helen Fornazier88ad71a2017-06-19 14:00:16 -0300199 .set_fmt = vimc_sen_set_fmt,
Helen Koikef2fe8902017-04-07 14:55:19 -0300200};
201
Lucas A. M. Magalhãesadc589d2019-01-21 20:05:01 -0500202static void *vimc_sen_process_frame(struct vimc_ent_device *ved,
203 const void *sink_frame)
Helen Koikef2fe8902017-04-07 14:55:19 -0300204{
Lucas A. M. Magalhãesadc589d2019-01-21 20:05:01 -0500205 struct vimc_sen_device *vsen = container_of(ved, struct vimc_sen_device,
206 ved);
207 const struct vimc_pix_map *vpix;
208 unsigned int frame_size;
Helen Koikef2fe8902017-04-07 14:55:19 -0300209
Lucas A. M. Magalhãesadc589d2019-01-21 20:05:01 -0500210 /* Calculate the frame size */
211 vpix = vimc_pix_map_by_code(vsen->mbus_format.code);
212 frame_size = vsen->mbus_format.width * vpix->bpp *
213 vsen->mbus_format.height;
Helen Koikef2fe8902017-04-07 14:55:19 -0300214
Lucas A. M. Magalhãesadc589d2019-01-21 20:05:01 -0500215 tpg_fill_plane_buffer(&vsen->tpg, 0, 0, vsen->frame);
216 return vsen->frame;
Helen Koikef2fe8902017-04-07 14:55:19 -0300217}
218
219static int vimc_sen_s_stream(struct v4l2_subdev *sd, int enable)
220{
221 struct vimc_sen_device *vsen =
222 container_of(sd, struct vimc_sen_device, sd);
Helen Koikef2fe8902017-04-07 14:55:19 -0300223
224 if (enable) {
225 const struct vimc_pix_map *vpix;
Helen Fornazier554946c2017-06-19 14:00:10 -0300226 unsigned int frame_size;
Helen Koikef2fe8902017-04-07 14:55:19 -0300227
228 if (vsen->kthread_sen)
Helen Fornazier554946c2017-06-19 14:00:10 -0300229 /* tpg is already executing */
230 return 0;
Helen Koikef2fe8902017-04-07 14:55:19 -0300231
232 /* Calculate the frame size */
233 vpix = vimc_pix_map_by_code(vsen->mbus_format.code);
Helen Fornazier554946c2017-06-19 14:00:10 -0300234 frame_size = vsen->mbus_format.width * vpix->bpp *
235 vsen->mbus_format.height;
Helen Koikef2fe8902017-04-07 14:55:19 -0300236
237 /*
238 * Allocate the frame buffer. Use vmalloc to be able to
239 * allocate a large amount of memory
240 */
Helen Fornazier554946c2017-06-19 14:00:10 -0300241 vsen->frame = vmalloc(frame_size);
Helen Koikef2fe8902017-04-07 14:55:19 -0300242 if (!vsen->frame)
243 return -ENOMEM;
244
Helen Fornazier554946c2017-06-19 14:00:10 -0300245 /* configure the test pattern generator */
246 vimc_sen_tpg_s_format(vsen);
247
Helen Koikef2fe8902017-04-07 14:55:19 -0300248 } else {
Helen Koikef2fe8902017-04-07 14:55:19 -0300249
Helen Koikef2fe8902017-04-07 14:55:19 -0300250 vfree(vsen->frame);
251 vsen->frame = NULL;
Helen Fornazier554946c2017-06-19 14:00:10 -0300252 return 0;
Helen Koikef2fe8902017-04-07 14:55:19 -0300253 }
254
255 return 0;
256}
257
Julia Lawallda411ab2018-10-27 08:49:05 -0400258static const struct v4l2_subdev_core_ops vimc_sen_core_ops = {
Hans Verkuil3da7ee92018-02-02 08:00:32 -0500259 .log_status = v4l2_ctrl_subdev_log_status,
260 .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
261 .unsubscribe_event = v4l2_event_subdev_unsubscribe,
262};
263
Julia Lawallebf7a642017-08-08 06:58:28 -0400264static const struct v4l2_subdev_video_ops vimc_sen_video_ops = {
Helen Koikef2fe8902017-04-07 14:55:19 -0300265 .s_stream = vimc_sen_s_stream,
266};
267
268static const struct v4l2_subdev_ops vimc_sen_ops = {
Hans Verkuil3da7ee92018-02-02 08:00:32 -0500269 .core = &vimc_sen_core_ops,
Helen Koikef2fe8902017-04-07 14:55:19 -0300270 .pad = &vimc_sen_pad_ops,
271 .video = &vimc_sen_video_ops,
272};
273
Hans Verkuil52cf1d92017-11-06 05:20:01 -0500274static int vimc_sen_s_ctrl(struct v4l2_ctrl *ctrl)
275{
276 struct vimc_sen_device *vsen =
277 container_of(ctrl->handler, struct vimc_sen_device, hdl);
278
279 switch (ctrl->id) {
280 case VIMC_CID_TEST_PATTERN:
281 tpg_s_pattern(&vsen->tpg, ctrl->val);
282 break;
283 case V4L2_CID_HFLIP:
284 tpg_s_hflip(&vsen->tpg, ctrl->val);
285 break;
286 case V4L2_CID_VFLIP:
287 tpg_s_vflip(&vsen->tpg, ctrl->val);
288 break;
Guilherme Gallo7b0bfa52018-09-03 21:45:59 -0400289 case V4L2_CID_BRIGHTNESS:
290 tpg_s_brightness(&vsen->tpg, ctrl->val);
291 break;
292 case V4L2_CID_CONTRAST:
293 tpg_s_contrast(&vsen->tpg, ctrl->val);
294 break;
295 case V4L2_CID_HUE:
296 tpg_s_hue(&vsen->tpg, ctrl->val);
297 break;
298 case V4L2_CID_SATURATION:
299 tpg_s_saturation(&vsen->tpg, ctrl->val);
300 break;
Hans Verkuil52cf1d92017-11-06 05:20:01 -0500301 default:
302 return -EINVAL;
303 }
304 return 0;
305}
306
307static const struct v4l2_ctrl_ops vimc_sen_ctrl_ops = {
308 .s_ctrl = vimc_sen_s_ctrl,
309};
310
Helen Fornazier4a29b702017-06-19 14:00:18 -0300311static void vimc_sen_comp_unbind(struct device *comp, struct device *master,
312 void *master_data)
Helen Koikef2fe8902017-04-07 14:55:19 -0300313{
Helen Fornazier4a29b702017-06-19 14:00:18 -0300314 struct vimc_ent_device *ved = dev_get_drvdata(comp);
Helen Koikef2fe8902017-04-07 14:55:19 -0300315 struct vimc_sen_device *vsen =
316 container_of(ved, struct vimc_sen_device, ved);
317
Helen Fornazierc1495432017-06-19 14:00:12 -0300318 vimc_ent_sd_unregister(ved, &vsen->sd);
Hans Verkuil52cf1d92017-11-06 05:20:01 -0500319 v4l2_ctrl_handler_free(&vsen->hdl);
Helen Fornazier554946c2017-06-19 14:00:10 -0300320 tpg_free(&vsen->tpg);
Helen Koikef2fe8902017-04-07 14:55:19 -0300321 kfree(vsen);
322}
323
Hans Verkuil52cf1d92017-11-06 05:20:01 -0500324/* Image Processing Controls */
325static const struct v4l2_ctrl_config vimc_sen_ctrl_class = {
326 .flags = V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY,
327 .id = VIMC_CID_VIMC_CLASS,
328 .name = "VIMC Controls",
329 .type = V4L2_CTRL_TYPE_CTRL_CLASS,
330};
331
332static const struct v4l2_ctrl_config vimc_sen_ctrl_test_pattern = {
333 .ops = &vimc_sen_ctrl_ops,
334 .id = VIMC_CID_TEST_PATTERN,
335 .name = "Test Pattern",
336 .type = V4L2_CTRL_TYPE_MENU,
337 .max = TPG_PAT_NOISE,
338 .qmenu = tpg_pattern_strings,
339};
340
Helen Fornazier4a29b702017-06-19 14:00:18 -0300341static int vimc_sen_comp_bind(struct device *comp, struct device *master,
342 void *master_data)
Helen Koikef2fe8902017-04-07 14:55:19 -0300343{
Helen Fornazier4a29b702017-06-19 14:00:18 -0300344 struct v4l2_device *v4l2_dev = master_data;
345 struct vimc_platform_data *pdata = comp->platform_data;
Helen Koikef2fe8902017-04-07 14:55:19 -0300346 struct vimc_sen_device *vsen;
Helen Koikef2fe8902017-04-07 14:55:19 -0300347 int ret;
348
Helen Koikef2fe8902017-04-07 14:55:19 -0300349 /* Allocate the vsen struct */
350 vsen = kzalloc(sizeof(*vsen), GFP_KERNEL);
351 if (!vsen)
Helen Fornazier4a29b702017-06-19 14:00:18 -0300352 return -ENOMEM;
Helen Koikef2fe8902017-04-07 14:55:19 -0300353
Hans Verkuil52cf1d92017-11-06 05:20:01 -0500354 v4l2_ctrl_handler_init(&vsen->hdl, 4);
355
356 v4l2_ctrl_new_custom(&vsen->hdl, &vimc_sen_ctrl_class, NULL);
357 v4l2_ctrl_new_custom(&vsen->hdl, &vimc_sen_ctrl_test_pattern, NULL);
358 v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops,
359 V4L2_CID_VFLIP, 0, 1, 1, 0);
360 v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops,
361 V4L2_CID_HFLIP, 0, 1, 1, 0);
Guilherme Gallo7b0bfa52018-09-03 21:45:59 -0400362 v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops,
363 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
364 v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops,
365 V4L2_CID_CONTRAST, 0, 255, 1, 128);
366 v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops,
367 V4L2_CID_HUE, -128, 127, 1, 0);
368 v4l2_ctrl_new_std(&vsen->hdl, &vimc_sen_ctrl_ops,
369 V4L2_CID_SATURATION, 0, 255, 1, 128);
Hans Verkuil52cf1d92017-11-06 05:20:01 -0500370 vsen->sd.ctrl_handler = &vsen->hdl;
371 if (vsen->hdl.error) {
372 ret = vsen->hdl.error;
373 goto err_free_vsen;
374 }
375
Helen Fornazierc1495432017-06-19 14:00:12 -0300376 /* Initialize ved and sd */
Helen Fornazier4a29b702017-06-19 14:00:18 -0300377 ret = vimc_ent_sd_register(&vsen->ved, &vsen->sd, v4l2_dev,
378 pdata->entity_name,
Hans Verkuil1ceda322018-02-07 12:06:30 -0500379 MEDIA_ENT_F_CAM_SENSOR, 1,
Helen Fornazier4a29b702017-06-19 14:00:18 -0300380 (const unsigned long[1]) {MEDIA_PAD_FL_SOURCE},
381 &vimc_sen_ops);
Helen Koikef2fe8902017-04-07 14:55:19 -0300382 if (ret)
Hans Verkuil52cf1d92017-11-06 05:20:01 -0500383 goto err_free_hdl;
Helen Koikef2fe8902017-04-07 14:55:19 -0300384
Lucas A. M. Magalhãesadc589d2019-01-21 20:05:01 -0500385 vsen->ved.process_frame = vimc_sen_process_frame;
Helen Fornazier4a29b702017-06-19 14:00:18 -0300386 dev_set_drvdata(comp, &vsen->ved);
387 vsen->dev = comp;
388
Helen Fornazier88ad71a2017-06-19 14:00:16 -0300389 /* Initialize the frame format */
390 vsen->mbus_format = fmt_default;
Helen Koikef2fe8902017-04-07 14:55:19 -0300391
Helen Fornazier554946c2017-06-19 14:00:10 -0300392 /* Initialize the test pattern generator */
393 tpg_init(&vsen->tpg, vsen->mbus_format.width,
394 vsen->mbus_format.height);
Helen Fornazier88ad71a2017-06-19 14:00:16 -0300395 ret = tpg_alloc(&vsen->tpg, VIMC_FRAME_MAX_WIDTH);
Helen Fornazier554946c2017-06-19 14:00:10 -0300396 if (ret)
Helen Fornazierc1495432017-06-19 14:00:12 -0300397 goto err_unregister_ent_sd;
Helen Koikef2fe8902017-04-07 14:55:19 -0300398
Helen Fornazier4a29b702017-06-19 14:00:18 -0300399 return 0;
Helen Koikef2fe8902017-04-07 14:55:19 -0300400
Helen Fornazierc1495432017-06-19 14:00:12 -0300401err_unregister_ent_sd:
402 vimc_ent_sd_unregister(&vsen->ved, &vsen->sd);
Hans Verkuil52cf1d92017-11-06 05:20:01 -0500403err_free_hdl:
404 v4l2_ctrl_handler_free(&vsen->hdl);
Helen Koikef2fe8902017-04-07 14:55:19 -0300405err_free_vsen:
406 kfree(vsen);
407
Helen Fornazier4a29b702017-06-19 14:00:18 -0300408 return ret;
Helen Koikef2fe8902017-04-07 14:55:19 -0300409}
Helen Fornazier4a29b702017-06-19 14:00:18 -0300410
411static const struct component_ops vimc_sen_comp_ops = {
412 .bind = vimc_sen_comp_bind,
413 .unbind = vimc_sen_comp_unbind,
414};
415
416static int vimc_sen_probe(struct platform_device *pdev)
417{
418 return component_add(&pdev->dev, &vimc_sen_comp_ops);
419}
420
421static int vimc_sen_remove(struct platform_device *pdev)
422{
423 component_del(&pdev->dev, &vimc_sen_comp_ops);
424
425 return 0;
426}
427
Helen Fornazier4a29b702017-06-19 14:00:18 -0300428static const struct platform_device_id vimc_sen_driver_ids[] = {
429 {
430 .name = VIMC_SEN_DRV_NAME,
431 },
432 { }
433};
434
Javier Martinez Canillasbb3abbb2017-07-14 05:58:39 -0300435static struct platform_driver vimc_sen_pdrv = {
436 .probe = vimc_sen_probe,
437 .remove = vimc_sen_remove,
438 .id_table = vimc_sen_driver_ids,
439 .driver = {
440 .name = VIMC_SEN_DRV_NAME,
441 },
442};
443
Helen Fornazier4a29b702017-06-19 14:00:18 -0300444module_platform_driver(vimc_sen_pdrv);
445
446MODULE_DEVICE_TABLE(platform, vimc_sen_driver_ids);
447
448MODULE_DESCRIPTION("Virtual Media Controller Driver (VIMC) Sensor");
449MODULE_AUTHOR("Helen Mae Koike Fornazier <helen.fornazier@gmail.com>");
450MODULE_LICENSE("GPL");