1 // SPDX-License-Identifier: GPL-2.0
3 * Support for Medifield PNW Camera Imaging ISP subsystem.
5 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
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.
18 #include <linux/module.h>
19 #include <linux/uaccess.h>
20 #include <linux/delay.h>
21 #include <linux/device.h>
23 #include <linux/sched.h>
24 #include <linux/slab.h>
26 #include <media/v4l2-event.h>
27 #include <media/v4l2-mediabus.h>
28 #include "atomisp_cmd.h"
29 #include "atomisp_common.h"
30 #include "atomisp_compat.h"
31 #include "atomisp_internal.h"
33 const struct atomisp_in_fmt_conv atomisp_in_fmt_conv[] = {
34 { MEDIA_BUS_FMT_SBGGR8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, IA_CSS_BAYER_ORDER_BGGR },
35 { MEDIA_BUS_FMT_SGBRG8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, IA_CSS_BAYER_ORDER_GBRG },
36 { MEDIA_BUS_FMT_SGRBG8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, IA_CSS_BAYER_ORDER_GRBG },
37 { MEDIA_BUS_FMT_SRGGB8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, IA_CSS_BAYER_ORDER_RGGB },
38 { MEDIA_BUS_FMT_SBGGR10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, IA_CSS_BAYER_ORDER_BGGR },
39 { MEDIA_BUS_FMT_SGBRG10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, IA_CSS_BAYER_ORDER_GBRG },
40 { MEDIA_BUS_FMT_SGRBG10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, IA_CSS_BAYER_ORDER_GRBG },
41 { MEDIA_BUS_FMT_SRGGB10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, IA_CSS_BAYER_ORDER_RGGB },
42 { MEDIA_BUS_FMT_SBGGR12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, IA_CSS_BAYER_ORDER_BGGR },
43 { MEDIA_BUS_FMT_SGBRG12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, IA_CSS_BAYER_ORDER_GBRG },
44 { MEDIA_BUS_FMT_SGRBG12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, IA_CSS_BAYER_ORDER_GRBG },
45 { MEDIA_BUS_FMT_SRGGB12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, IA_CSS_BAYER_ORDER_RGGB },
46 { MEDIA_BUS_FMT_UYVY8_1X16, 8, 8, ATOMISP_INPUT_FORMAT_YUV422_8, 0 },
47 { MEDIA_BUS_FMT_YUYV8_1X16, 8, 8, ATOMISP_INPUT_FORMAT_YUV422_8, 0 },
48 #if 0 // disabled due to clang warnings
49 { MEDIA_BUS_FMT_JPEG_1X8, 8, 8, IA_CSS_FRAME_FORMAT_BINARY_8, 0 },
50 { V4L2_MBUS_FMT_CUSTOM_NV12, 12, 12, IA_CSS_FRAME_FORMAT_NV12, 0 },
51 { V4L2_MBUS_FMT_CUSTOM_NV21, 12, 12, IA_CSS_FRAME_FORMAT_NV21, 0 },
53 { V4L2_MBUS_FMT_CUSTOM_YUV420, 12, 12, ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY, 0 },
55 { V4L2_MBUS_FMT_CUSTOM_M10MO_RAW, 8, 8, IA_CSS_FRAME_FORMAT_BINARY_8, 0 },
57 /* no valid V4L2 MBUS code for metadata format, so leave it 0. */
58 { 0, 0, 0, ATOMISP_INPUT_FORMAT_EMBEDDED, 0 },
65 } compressed_codes[] = {
66 { MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8 },
67 { MEDIA_BUS_FMT_SGBRG10_1X10, MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8 },
68 { MEDIA_BUS_FMT_SGRBG10_1X10, MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8 },
69 { MEDIA_BUS_FMT_SRGGB10_1X10, MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8 },
72 u32 atomisp_subdev_uncompressed_code(u32 code)
76 for (i = 0; i < ARRAY_SIZE(compressed_codes); i++)
77 if (code == compressed_codes[i].compressed)
78 return compressed_codes[i].code;
83 bool atomisp_subdev_is_compressed(u32 code)
87 for (i = 0; i < ARRAY_SIZE(atomisp_in_fmt_conv) - 1; i++)
88 if (code == atomisp_in_fmt_conv[i].code)
89 return atomisp_in_fmt_conv[i].bpp !=
90 atomisp_in_fmt_conv[i].depth;
95 const struct atomisp_in_fmt_conv *atomisp_find_in_fmt_conv(u32 code)
99 for (i = 0; i < ARRAY_SIZE(atomisp_in_fmt_conv) - 1; i++)
100 if (code == atomisp_in_fmt_conv[i].code)
101 return atomisp_in_fmt_conv + i;
106 const struct atomisp_in_fmt_conv *atomisp_find_in_fmt_conv_by_atomisp_in_fmt(
107 enum atomisp_input_format atomisp_in_fmt)
111 for (i = 0; i < ARRAY_SIZE(atomisp_in_fmt_conv) - 1; i++)
112 if (atomisp_in_fmt_conv[i].atomisp_in_fmt == atomisp_in_fmt)
113 return atomisp_in_fmt_conv + i;
118 bool atomisp_subdev_format_conversion(struct atomisp_sub_device *asd,
119 unsigned int source_pad)
121 struct v4l2_mbus_framefmt *sink, *src;
123 sink = atomisp_subdev_get_ffmt(&asd->subdev, NULL,
124 V4L2_SUBDEV_FORMAT_ACTIVE,
125 ATOMISP_SUBDEV_PAD_SINK);
126 src = atomisp_subdev_get_ffmt(&asd->subdev, NULL,
127 V4L2_SUBDEV_FORMAT_ACTIVE, source_pad);
129 return atomisp_is_mbuscode_raw(sink->code)
130 && !atomisp_is_mbuscode_raw(src->code);
133 uint16_t atomisp_subdev_source_pad(struct video_device *vdev)
135 struct media_link *link;
138 list_for_each_entry(link, &vdev->entity.links, list) {
140 ret = link->source->index;
148 * V4L2 subdev operations
152 * isp_subdev_ioctl - CCDC module private ioctl's
153 * @sd: ISP V4L2 subdevice
154 * @cmd: ioctl command
155 * @arg: ioctl argument
157 * Return 0 on success or a negative error code otherwise.
159 static long isp_subdev_ioctl(struct v4l2_subdev *sd,
160 unsigned int cmd, void *arg)
166 * isp_subdev_set_power - Power on/off the CCDC module
167 * @sd: ISP V4L2 subdevice
170 * Return 0 on success or a negative error code otherwise.
172 static int isp_subdev_set_power(struct v4l2_subdev *sd, int on)
177 static int isp_subdev_subscribe_event(struct v4l2_subdev *sd,
179 struct v4l2_event_subscription *sub)
181 struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
182 struct atomisp_device *isp = isp_sd->isp;
184 if (sub->type != V4L2_EVENT_FRAME_SYNC &&
185 sub->type != V4L2_EVENT_FRAME_END &&
186 sub->type != V4L2_EVENT_ATOMISP_3A_STATS_READY &&
187 sub->type != V4L2_EVENT_ATOMISP_METADATA_READY &&
188 sub->type != V4L2_EVENT_ATOMISP_PAUSE_BUFFER &&
189 sub->type != V4L2_EVENT_ATOMISP_CSS_RESET &&
190 sub->type != V4L2_EVENT_ATOMISP_RAW_BUFFERS_ALLOC_DONE &&
191 sub->type != V4L2_EVENT_ATOMISP_ACC_COMPLETE)
194 if (sub->type == V4L2_EVENT_FRAME_SYNC &&
195 !atomisp_css_valid_sof(isp))
198 return v4l2_event_subscribe(fh, sub, 16, NULL);
201 static int isp_subdev_unsubscribe_event(struct v4l2_subdev *sd,
203 struct v4l2_event_subscription *sub)
205 return v4l2_event_unsubscribe(fh, sub);
209 * isp_subdev_enum_mbus_code - Handle pixel format enumeration
210 * @sd: pointer to v4l2 subdev structure
211 * @fh : V4L2 subdev file handle
212 * @code: pointer to v4l2_subdev_pad_mbus_code_enum structure
213 * return -EINVAL or zero on success
215 static int isp_subdev_enum_mbus_code(struct v4l2_subdev *sd,
216 struct v4l2_subdev_state *sd_state,
217 struct v4l2_subdev_mbus_code_enum *code)
219 if (code->index >= ARRAY_SIZE(atomisp_in_fmt_conv) - 1)
222 code->code = atomisp_in_fmt_conv[code->index].code;
227 static int isp_subdev_validate_rect(struct v4l2_subdev *sd, uint32_t pad,
231 case ATOMISP_SUBDEV_PAD_SINK:
233 case V4L2_SEL_TGT_CROP:
239 case V4L2_SEL_TGT_COMPOSE:
248 struct v4l2_rect *atomisp_subdev_get_rect(struct v4l2_subdev *sd,
249 struct v4l2_subdev_state *sd_state,
250 u32 which, uint32_t pad,
253 struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
255 if (which == V4L2_SUBDEV_FORMAT_TRY) {
257 case V4L2_SEL_TGT_CROP:
258 return v4l2_subdev_get_try_crop(sd, sd_state, pad);
259 case V4L2_SEL_TGT_COMPOSE:
260 return v4l2_subdev_get_try_compose(sd, sd_state, pad);
265 case V4L2_SEL_TGT_CROP:
266 return &isp_sd->fmt[pad].crop;
267 case V4L2_SEL_TGT_COMPOSE:
268 return &isp_sd->fmt[pad].compose;
274 struct v4l2_mbus_framefmt
275 *atomisp_subdev_get_ffmt(struct v4l2_subdev *sd,
276 struct v4l2_subdev_state *sd_state, uint32_t which,
279 struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
281 if (which == V4L2_SUBDEV_FORMAT_TRY)
282 return v4l2_subdev_get_try_format(sd, sd_state, pad);
284 return &isp_sd->fmt[pad].fmt;
287 static void isp_get_fmt_rect(struct v4l2_subdev *sd,
288 struct v4l2_subdev_state *sd_state,
290 struct v4l2_mbus_framefmt **ffmt,
291 struct v4l2_rect *crop[ATOMISP_SUBDEV_PADS_NUM],
292 struct v4l2_rect *comp[ATOMISP_SUBDEV_PADS_NUM])
296 for (i = 0; i < ATOMISP_SUBDEV_PADS_NUM; i++) {
297 ffmt[i] = atomisp_subdev_get_ffmt(sd, sd_state, which, i);
298 crop[i] = atomisp_subdev_get_rect(sd, sd_state, which, i,
300 comp[i] = atomisp_subdev_get_rect(sd, sd_state, which, i,
301 V4L2_SEL_TGT_COMPOSE);
305 static void isp_subdev_propagate(struct v4l2_subdev *sd,
306 struct v4l2_subdev_state *sd_state,
307 u32 which, uint32_t pad, uint32_t target,
310 struct v4l2_mbus_framefmt *ffmt[ATOMISP_SUBDEV_PADS_NUM];
311 struct v4l2_rect *crop[ATOMISP_SUBDEV_PADS_NUM],
312 *comp[ATOMISP_SUBDEV_PADS_NUM];
314 if (flags & V4L2_SEL_FLAG_KEEP_CONFIG)
317 isp_get_fmt_rect(sd, sd_state, which, ffmt, crop, comp);
320 case ATOMISP_SUBDEV_PAD_SINK: {
321 struct v4l2_rect r = {0};
323 /* Only crop target supported on sink pad. */
324 r.width = ffmt[pad]->width;
325 r.height = ffmt[pad]->height;
327 atomisp_subdev_set_selection(sd, sd_state, which, pad,
334 static int isp_subdev_get_selection(struct v4l2_subdev *sd,
335 struct v4l2_subdev_state *sd_state,
336 struct v4l2_subdev_selection *sel)
338 struct v4l2_rect *rec;
339 int rval = isp_subdev_validate_rect(sd, sel->pad, sel->target);
344 rec = atomisp_subdev_get_rect(sd, sd_state, sel->which, sel->pad,
353 static const char *atomisp_pad_str(unsigned int pad)
355 static const char *const pad_str[] = {
356 "ATOMISP_SUBDEV_PAD_SINK",
357 "ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE",
358 "ATOMISP_SUBDEV_PAD_SOURCE_VF",
359 "ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW",
360 "ATOMISP_SUBDEV_PAD_SOURCE_VIDEO",
363 if (pad >= ARRAY_SIZE(pad_str))
364 return "ATOMISP_INVALID_PAD";
368 int atomisp_subdev_set_selection(struct v4l2_subdev *sd,
369 struct v4l2_subdev_state *sd_state,
370 u32 which, uint32_t pad, uint32_t target,
371 u32 flags, struct v4l2_rect *r)
373 struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
374 struct atomisp_device *isp = isp_sd->isp;
375 struct v4l2_mbus_framefmt *ffmt[ATOMISP_SUBDEV_PADS_NUM];
376 u16 vdev_pad = atomisp_subdev_source_pad(sd->devnode);
377 struct v4l2_rect *crop[ATOMISP_SUBDEV_PADS_NUM],
378 *comp[ATOMISP_SUBDEV_PADS_NUM];
379 enum atomisp_input_stream_id stream_id;
381 unsigned int padding_w = pad_w;
382 unsigned int padding_h = pad_h;
384 stream_id = atomisp_source_pad_to_stream_id(isp_sd, vdev_pad);
386 isp_get_fmt_rect(sd, sd_state, which, ffmt, crop, comp);
389 "sel: pad %s tgt %s l %d t %d w %d h %d which %s f 0x%8.8x\n",
390 atomisp_pad_str(pad), target == V4L2_SEL_TGT_CROP
391 ? "V4L2_SEL_TGT_CROP" : "V4L2_SEL_TGT_COMPOSE",
392 r->left, r->top, r->width, r->height,
393 which == V4L2_SUBDEV_FORMAT_TRY ? "V4L2_SUBDEV_FORMAT_TRY"
394 : "V4L2_SUBDEV_FORMAT_ACTIVE", flags);
396 r->width = rounddown(r->width, ATOM_ISP_STEP_WIDTH);
397 r->height = rounddown(r->height, ATOM_ISP_STEP_HEIGHT);
400 case ATOMISP_SUBDEV_PAD_SINK: {
401 /* Only crop target supported on sink pad. */
402 unsigned int dvs_w, dvs_h;
404 crop[pad]->width = ffmt[pad]->width;
405 crop[pad]->height = ffmt[pad]->height;
407 /* Workaround for BYT 1080p perfectshot since the maxinum resolution of
408 * front camera ov2722 is 1932x1092 and cannot use pad_w > 12*/
409 if (!strncmp(isp->inputs[isp_sd->input_curr].camera->name,
410 "ov2722", 6) && crop[pad]->height == 1092) {
415 if (isp->inputs[isp_sd->input_curr].type == SOC_CAMERA) {
420 if (atomisp_subdev_format_conversion(isp_sd,
422 && crop[pad]->width && crop[pad]->height) {
423 crop[pad]->width -= padding_w;
424 crop[pad]->height -= padding_h;
427 /* if subdev type is SOC camera,we do not need to set DVS */
428 if (isp->inputs[isp_sd->input_curr].type == SOC_CAMERA)
429 isp_sd->params.video_dis_en = 0;
431 if (isp_sd->params.video_dis_en &&
432 isp_sd->run_mode->val == ATOMISP_RUN_MODE_VIDEO &&
433 !isp_sd->continuous_mode->val) {
434 /* This resolution contains 20 % of DVS slack
435 * (of the desired captured image before
436 * scaling, or 1 / 6 of what we get from the
437 * sensor) in both width and height. Remove
439 crop[pad]->width = roundup(crop[pad]->width * 5 / 6,
440 ATOM_ISP_STEP_WIDTH);
441 crop[pad]->height = roundup(crop[pad]->height * 5 / 6,
442 ATOM_ISP_STEP_HEIGHT);
445 crop[pad]->width = min(crop[pad]->width, r->width);
446 crop[pad]->height = min(crop[pad]->height, r->height);
448 if (!(flags & V4L2_SEL_FLAG_KEEP_CONFIG)) {
449 for (i = ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE;
450 i < ATOMISP_SUBDEV_PADS_NUM; i++) {
451 struct v4l2_rect tmp = *crop[pad];
453 atomisp_subdev_set_selection(
454 sd, sd_state, which, i,
455 V4L2_SEL_TGT_COMPOSE,
460 if (which == V4L2_SUBDEV_FORMAT_TRY)
463 if (isp_sd->params.video_dis_en &&
464 isp_sd->run_mode->val == ATOMISP_RUN_MODE_VIDEO &&
465 !isp_sd->continuous_mode->val) {
466 dvs_w = rounddown(crop[pad]->width / 5,
467 ATOM_ISP_STEP_WIDTH);
468 dvs_h = rounddown(crop[pad]->height / 5,
469 ATOM_ISP_STEP_HEIGHT);
470 } else if (!isp_sd->params.video_dis_en &&
471 isp_sd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
473 * For CSS2.0, digital zoom needs to set dvs envelope to 12
474 * when dvs is disabled.
480 atomisp_css_video_set_dis_envelope(isp_sd, dvs_w, dvs_h);
481 atomisp_css_input_set_effective_resolution(isp_sd, stream_id,
482 crop[pad]->width, crop[pad]->height);
486 case ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE:
487 case ATOMISP_SUBDEV_PAD_SOURCE_VIDEO: {
488 /* Only compose target is supported on source pads. */
490 if (isp_sd->vfpp->val == ATOMISP_VFPP_DISABLE_LOWLAT) {
491 /* Scaling is disabled in this mode */
492 r->width = crop[ATOMISP_SUBDEV_PAD_SINK]->width;
493 r->height = crop[ATOMISP_SUBDEV_PAD_SINK]->height;
496 if (crop[ATOMISP_SUBDEV_PAD_SINK]->width == r->width
497 && crop[ATOMISP_SUBDEV_PAD_SINK]->height == r->height)
498 isp_sd->params.yuv_ds_en = false;
500 isp_sd->params.yuv_ds_en = true;
502 comp[pad]->width = r->width;
503 comp[pad]->height = r->height;
505 if (r->width == 0 || r->height == 0 ||
506 crop[ATOMISP_SUBDEV_PAD_SINK]->width == 0 ||
507 crop[ATOMISP_SUBDEV_PAD_SINK]->height == 0)
510 * do cropping on sensor input if ratio of required resolution
511 * is different with sensor output resolution ratio:
513 * ratio = width / height
515 * if ratio_output < ratio_sensor:
516 * effect_width = sensor_height * out_width / out_height;
517 * effect_height = sensor_height;
519 * effect_width = sensor_width;
520 * effect_height = sensor_width * out_height / out_width;
523 if (r->width * crop[ATOMISP_SUBDEV_PAD_SINK]->height <
524 crop[ATOMISP_SUBDEV_PAD_SINK]->width * r->height)
525 atomisp_css_input_set_effective_resolution(isp_sd,
527 rounddown(crop[ATOMISP_SUBDEV_PAD_SINK]->
528 height * r->width / r->height,
529 ATOM_ISP_STEP_WIDTH),
530 crop[ATOMISP_SUBDEV_PAD_SINK]->height);
532 atomisp_css_input_set_effective_resolution(isp_sd,
534 crop[ATOMISP_SUBDEV_PAD_SINK]->width,
535 rounddown(crop[ATOMISP_SUBDEV_PAD_SINK]->
536 width * r->height / r->width,
537 ATOM_ISP_STEP_WIDTH));
541 case ATOMISP_SUBDEV_PAD_SOURCE_VF:
542 case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW:
543 comp[pad]->width = r->width;
544 comp[pad]->height = r->height;
550 /* Set format dimensions on non-sink pads as well. */
551 if (pad != ATOMISP_SUBDEV_PAD_SINK) {
552 ffmt[pad]->width = comp[pad]->width;
553 ffmt[pad]->height = comp[pad]->height;
556 if (!atomisp_subdev_get_rect(sd, sd_state, which, pad, target))
558 *r = *atomisp_subdev_get_rect(sd, sd_state, which, pad, target);
560 dev_dbg(isp->dev, "sel actual: l %d t %d w %d h %d\n",
561 r->left, r->top, r->width, r->height);
566 static int isp_subdev_set_selection(struct v4l2_subdev *sd,
567 struct v4l2_subdev_state *sd_state,
568 struct v4l2_subdev_selection *sel)
570 int rval = isp_subdev_validate_rect(sd, sel->pad, sel->target);
575 return atomisp_subdev_set_selection(sd, sd_state, sel->which,
577 sel->target, sel->flags, &sel->r);
580 static int atomisp_get_sensor_bin_factor(struct atomisp_sub_device *asd)
582 struct v4l2_control ctrl = {0};
583 struct atomisp_device *isp = asd->isp;
587 if (isp->inputs[asd->input_curr].type == FILE_INPUT ||
588 isp->inputs[asd->input_curr].type == TEST_PATTERN)
591 ctrl.id = V4L2_CID_BIN_FACTOR_HORZ;
593 v4l2_g_ctrl(isp->inputs[asd->input_curr].camera->ctrl_handler,
596 ctrl.id = V4L2_CID_BIN_FACTOR_VERT;
598 v4l2_g_ctrl(isp->inputs[asd->input_curr].camera->ctrl_handler,
603 * ISP needs to know binning factor from sensor.
604 * In case horizontal and vertical sensor's binning factors
605 * are different or sensor does not support binning factor CID,
606 * ISP will apply default 0 value.
608 if (ret || hbin != vbin)
614 void atomisp_subdev_set_ffmt(struct v4l2_subdev *sd,
615 struct v4l2_subdev_state *sd_state,
617 u32 pad, struct v4l2_mbus_framefmt *ffmt)
619 struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
620 struct atomisp_device *isp = isp_sd->isp;
621 struct v4l2_mbus_framefmt *__ffmt =
622 atomisp_subdev_get_ffmt(sd, sd_state, which, pad);
623 u16 vdev_pad = atomisp_subdev_source_pad(sd->devnode);
624 enum atomisp_input_stream_id stream_id;
626 dev_dbg(isp->dev, "ffmt: pad %s w %d h %d code 0x%8.8x which %s\n",
627 atomisp_pad_str(pad), ffmt->width, ffmt->height, ffmt->code,
628 which == V4L2_SUBDEV_FORMAT_TRY ? "V4L2_SUBDEV_FORMAT_TRY"
629 : "V4L2_SUBDEV_FORMAT_ACTIVE");
631 stream_id = atomisp_source_pad_to_stream_id(isp_sd, vdev_pad);
634 case ATOMISP_SUBDEV_PAD_SINK: {
635 const struct atomisp_in_fmt_conv *fc =
636 atomisp_find_in_fmt_conv(ffmt->code);
639 fc = atomisp_in_fmt_conv;
640 ffmt->code = fc->code;
641 dev_dbg(isp->dev, "using 0x%8.8x instead\n",
647 isp_subdev_propagate(sd, sd_state, which, pad,
648 V4L2_SEL_TGT_CROP, 0);
650 if (which == V4L2_SUBDEV_FORMAT_ACTIVE) {
651 atomisp_css_input_set_resolution(isp_sd,
653 atomisp_css_input_set_binning_factor(isp_sd,
655 atomisp_get_sensor_bin_factor(isp_sd));
656 atomisp_css_input_set_bayer_order(isp_sd, stream_id,
658 atomisp_css_input_set_format(isp_sd, stream_id,
660 atomisp_css_set_default_isys_config(isp_sd, stream_id,
666 case ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE:
667 case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW:
668 case ATOMISP_SUBDEV_PAD_SOURCE_VF:
669 case ATOMISP_SUBDEV_PAD_SOURCE_VIDEO:
670 __ffmt->code = ffmt->code;
676 * isp_subdev_get_format - Retrieve the video format on a pad
677 * @sd : ISP V4L2 subdevice
678 * @fh : V4L2 subdev file handle
682 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
683 * to the format type.
685 static int isp_subdev_get_format(struct v4l2_subdev *sd,
686 struct v4l2_subdev_state *sd_state,
687 struct v4l2_subdev_format *fmt)
689 fmt->format = *atomisp_subdev_get_ffmt(sd, sd_state, fmt->which,
696 * isp_subdev_set_format - Set the video format on a pad
697 * @sd : ISP subdev V4L2 subdevice
698 * @fh : V4L2 subdev file handle
702 * Return 0 on success or -EINVAL if the pad is invalid or doesn't correspond
703 * to the format type.
705 static int isp_subdev_set_format(struct v4l2_subdev *sd,
706 struct v4l2_subdev_state *sd_state,
707 struct v4l2_subdev_format *fmt)
709 atomisp_subdev_set_ffmt(sd, sd_state, fmt->which, fmt->pad,
715 /* V4L2 subdev core operations */
716 static const struct v4l2_subdev_core_ops isp_subdev_v4l2_core_ops = {
717 .ioctl = isp_subdev_ioctl, .s_power = isp_subdev_set_power,
718 .subscribe_event = isp_subdev_subscribe_event,
719 .unsubscribe_event = isp_subdev_unsubscribe_event,
722 /* V4L2 subdev pad operations */
723 static const struct v4l2_subdev_pad_ops isp_subdev_v4l2_pad_ops = {
724 .enum_mbus_code = isp_subdev_enum_mbus_code,
725 .get_fmt = isp_subdev_get_format,
726 .set_fmt = isp_subdev_set_format,
727 .get_selection = isp_subdev_get_selection,
728 .set_selection = isp_subdev_set_selection,
729 .link_validate = v4l2_subdev_link_validate_default,
732 /* V4L2 subdev operations */
733 static const struct v4l2_subdev_ops isp_subdev_v4l2_ops = {
734 .core = &isp_subdev_v4l2_core_ops,
735 .pad = &isp_subdev_v4l2_pad_ops,
738 static void isp_subdev_init_params(struct atomisp_sub_device *asd)
742 /* parameters initialization */
743 INIT_LIST_HEAD(&asd->s3a_stats);
744 INIT_LIST_HEAD(&asd->s3a_stats_in_css);
745 INIT_LIST_HEAD(&asd->s3a_stats_ready);
746 INIT_LIST_HEAD(&asd->dis_stats);
747 INIT_LIST_HEAD(&asd->dis_stats_in_css);
748 spin_lock_init(&asd->dis_stats_lock);
749 for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
750 INIT_LIST_HEAD(&asd->metadata[i]);
751 INIT_LIST_HEAD(&asd->metadata_in_css[i]);
752 INIT_LIST_HEAD(&asd->metadata_ready[i]);
757 * isp_subdev_link_setup - Setup isp subdev connections
758 * @entity: ispsubdev media entity
759 * @local: Pad at the local end of the link
760 * @remote: Pad at the remote end of the link
763 * return -EINVAL or zero on success
765 static int isp_subdev_link_setup(struct media_entity *entity,
766 const struct media_pad *local,
767 const struct media_pad *remote, u32 flags)
769 struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
770 struct atomisp_sub_device *isp_sd = v4l2_get_subdevdata(sd);
771 struct atomisp_device *isp = isp_sd->isp;
774 switch (local->index | is_media_entity_v4l2_subdev(remote->entity)) {
775 case ATOMISP_SUBDEV_PAD_SINK | MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN:
776 /* Read from the sensor CSI2-ports. */
777 if (!(flags & MEDIA_LNK_FL_ENABLED)) {
778 isp_sd->input = ATOMISP_SUBDEV_INPUT_NONE;
782 if (isp_sd->input != ATOMISP_SUBDEV_INPUT_NONE)
785 for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) {
786 if (remote->entity != &isp->csi2_port[i].subdev.entity)
789 isp_sd->input = ATOMISP_SUBDEV_INPUT_CSI2_PORT1 + i;
795 case ATOMISP_SUBDEV_PAD_SINK | MEDIA_ENT_F_OLD_BASE:
796 /* read from memory */
797 if (flags & MEDIA_LNK_FL_ENABLED) {
798 if (isp_sd->input >= ATOMISP_SUBDEV_INPUT_CSI2_PORT1 &&
799 isp_sd->input < (ATOMISP_SUBDEV_INPUT_CSI2_PORT1
800 + ATOMISP_CAMERA_NR_PORTS))
802 isp_sd->input = ATOMISP_SUBDEV_INPUT_MEMORY;
804 if (isp_sd->input == ATOMISP_SUBDEV_INPUT_MEMORY)
805 isp_sd->input = ATOMISP_SUBDEV_INPUT_NONE;
809 case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW | MEDIA_ENT_F_OLD_BASE:
810 /* always write to memory */
813 case ATOMISP_SUBDEV_PAD_SOURCE_VF | MEDIA_ENT_F_OLD_BASE:
814 /* always write to memory */
817 case ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE | MEDIA_ENT_F_OLD_BASE:
818 /* always write to memory */
821 case ATOMISP_SUBDEV_PAD_SOURCE_VIDEO | MEDIA_ENT_F_OLD_BASE:
822 /* always write to memory */
832 /* media operations */
833 static const struct media_entity_operations isp_subdev_media_ops = {
834 .link_setup = isp_subdev_link_setup,
835 .link_validate = v4l2_subdev_link_validate,
836 /* .set_power = v4l2_subdev_set_power, */
839 static int __atomisp_update_run_mode(struct atomisp_sub_device *asd)
841 struct atomisp_device *isp = asd->isp;
842 struct v4l2_ctrl *ctrl = asd->run_mode;
846 if (ctrl->val != ATOMISP_RUN_MODE_VIDEO &&
847 asd->continuous_mode->val)
848 mode = ATOMISP_RUN_MODE_PREVIEW;
853 isp->inputs[asd->input_curr].camera->ctrl_handler,
857 return v4l2_ctrl_s_ctrl(c, mode);
862 int atomisp_update_run_mode(struct atomisp_sub_device *asd)
866 mutex_lock(asd->ctrl_handler.lock);
867 rval = __atomisp_update_run_mode(asd);
868 mutex_unlock(asd->ctrl_handler.lock);
873 static int s_ctrl(struct v4l2_ctrl *ctrl)
875 struct atomisp_sub_device *asd = container_of(
876 ctrl->handler, struct atomisp_sub_device, ctrl_handler);
879 case V4L2_CID_RUN_MODE:
880 return __atomisp_update_run_mode(asd);
881 case V4L2_CID_DEPTH_MODE:
882 if (asd->streaming != ATOMISP_DEVICE_STREAMING_DISABLED) {
883 dev_err(asd->isp->dev,
884 "ISP is streaming, it is not supported to change the depth mode\n");
893 static const struct v4l2_ctrl_ops ctrl_ops = {
897 static const struct v4l2_ctrl_config ctrl_fmt_auto = {
899 .id = V4L2_CID_FMT_AUTO,
900 .name = "Automatic format guessing",
901 .type = V4L2_CTRL_TYPE_BOOLEAN,
908 static const char *const ctrl_run_mode_menu[] = {
912 "Continuous capture",
916 static const struct v4l2_ctrl_config ctrl_run_mode = {
918 .id = V4L2_CID_RUN_MODE,
919 .name = "Atomisp run mode",
920 .type = V4L2_CTRL_TYPE_MENU,
924 .qmenu = ctrl_run_mode_menu,
927 static const char *const ctrl_vfpp_mode_menu[] = {
928 "Enable", /* vfpp always enabled */
929 "Disable to scaler mode", /* CSS into video mode and disable */
930 "Disable to low latency mode", /* CSS into still mode and disable */
933 static const struct v4l2_ctrl_config ctrl_vfpp = {
935 .name = "Atomisp vf postprocess",
936 .type = V4L2_CTRL_TYPE_MENU,
940 .qmenu = ctrl_vfpp_mode_menu,
944 * Control for ISP continuous mode
946 * When enabled, capture processing is possible without
947 * stopping the preview pipeline. When disabled, ISP needs
948 * to be restarted between preview and capture.
950 static const struct v4l2_ctrl_config ctrl_continuous_mode = {
952 .id = V4L2_CID_ATOMISP_CONTINUOUS_MODE,
953 .type = V4L2_CTRL_TYPE_BOOLEAN,
954 .name = "Continuous mode",
962 * Control for continuous mode raw buffer size
964 * The size of the RAW ringbuffer sets limit on how much
965 * back in time application can go when requesting capture
966 * frames to be rendered, and how many frames can be rendered
967 * in a burst at full sensor rate.
969 * Note: this setting has a big impact on memory consumption of
972 static const struct v4l2_ctrl_config ctrl_continuous_raw_buffer_size = {
974 .id = V4L2_CID_ATOMISP_CONTINUOUS_RAW_BUFFER_SIZE,
975 .type = V4L2_CTRL_TYPE_INTEGER,
976 .name = "Continuous raw ringbuffer size",
978 .max = 100, /* depends on CSS version, runtime checked */
984 * Control for enabling continuous viewfinder
986 * When enabled, and ISP is in continuous mode (see ctrl_continuous_mode ),
987 * preview pipeline continues concurrently with capture
988 * processing. When disabled, and continuous mode is used,
989 * preview is paused while captures are processed, but
990 * full pipeline restart is not needed.
992 * By setting this to disabled, capture processing is
993 * essentially given priority over preview, and the effective
994 * capture output rate may be higher than with continuous
995 * viewfinder enabled.
997 static const struct v4l2_ctrl_config ctrl_continuous_viewfinder = {
998 .id = V4L2_CID_ATOMISP_CONTINUOUS_VIEWFINDER,
999 .type = V4L2_CTRL_TYPE_BOOLEAN,
1000 .name = "Continuous viewfinder",
1008 * Control for enabling Lock&Unlock Raw Buffer mechanism
1010 * When enabled, Raw Buffer can be locked and unlocked.
1011 * Application can hold the exp_id of Raw Buffer
1012 * and unlock it when no longer needed.
1013 * Note: Make sure set this configuration before creating stream.
1015 static const struct v4l2_ctrl_config ctrl_enable_raw_buffer_lock = {
1016 .id = V4L2_CID_ENABLE_RAW_BUFFER_LOCK,
1017 .type = V4L2_CTRL_TYPE_BOOLEAN,
1018 .name = "Lock Unlock Raw Buffer",
1026 * Control to disable digital zoom of the whole stream
1028 * When it is true, pipe configuration enable_dz will be set to false.
1029 * This can help get a better performance by disabling pp binary.
1031 * Note: Make sure set this configuration before creating stream.
1033 static const struct v4l2_ctrl_config ctrl_disable_dz = {
1034 .id = V4L2_CID_DISABLE_DZ,
1035 .type = V4L2_CTRL_TYPE_BOOLEAN,
1036 .name = "Disable digital zoom",
1044 * Control for ISP depth mode
1046 * When enabled, that means ISP will deal with dual streams and sensors will be
1047 * in slave/master mode.
1048 * slave sensor will have no output until master sensor is streamed on.
1050 static const struct v4l2_ctrl_config ctrl_depth_mode = {
1052 .id = V4L2_CID_DEPTH_MODE,
1053 .type = V4L2_CTRL_TYPE_BOOLEAN,
1054 .name = "Depth mode",
1061 static void atomisp_init_subdev_pipe(struct atomisp_sub_device *asd,
1062 struct atomisp_video_pipe *pipe, enum v4l2_buf_type buf_type)
1064 pipe->type = buf_type;
1066 pipe->isp = asd->isp;
1067 spin_lock_init(&pipe->irq_lock);
1068 INIT_LIST_HEAD(&pipe->activeq);
1069 INIT_LIST_HEAD(&pipe->activeq_out);
1070 INIT_LIST_HEAD(&pipe->buffers_waiting_for_param);
1071 INIT_LIST_HEAD(&pipe->per_frame_params);
1072 memset(pipe->frame_request_config_id,
1073 0, VIDEO_MAX_FRAME * sizeof(unsigned int));
1074 memset(pipe->frame_params,
1075 0, VIDEO_MAX_FRAME *
1076 sizeof(struct atomisp_css_params_with_list *));
1079 static void atomisp_init_acc_pipe(struct atomisp_sub_device *asd,
1080 struct atomisp_acc_pipe *pipe)
1083 pipe->isp = asd->isp;
1084 INIT_LIST_HEAD(&asd->acc.fw);
1085 INIT_LIST_HEAD(&asd->acc.memory_maps);
1086 ida_init(&asd->acc.ida);
1090 * isp_subdev_init_entities - Initialize V4L2 subdev and media entity
1091 * @asd: ISP CCDC module
1093 * Return 0 on success and a negative error code on failure.
1095 static int isp_subdev_init_entities(struct atomisp_sub_device *asd)
1097 struct v4l2_subdev *sd = &asd->subdev;
1098 struct media_pad *pads = asd->pads;
1099 struct media_entity *me = &sd->entity;
1102 asd->input = ATOMISP_SUBDEV_INPUT_NONE;
1104 v4l2_subdev_init(sd, &isp_subdev_v4l2_ops);
1105 sprintf(sd->name, "ATOMISP_SUBDEV_%d", asd->index);
1106 v4l2_set_subdevdata(sd, asd);
1107 sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE;
1109 pads[ATOMISP_SUBDEV_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
1110 pads[ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW].flags = MEDIA_PAD_FL_SOURCE;
1111 pads[ATOMISP_SUBDEV_PAD_SOURCE_VF].flags = MEDIA_PAD_FL_SOURCE;
1112 pads[ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE].flags = MEDIA_PAD_FL_SOURCE;
1113 pads[ATOMISP_SUBDEV_PAD_SOURCE_VIDEO].flags = MEDIA_PAD_FL_SOURCE;
1115 asd->fmt[ATOMISP_SUBDEV_PAD_SINK].fmt.code =
1116 MEDIA_BUS_FMT_SBGGR10_1X10;
1117 asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW].fmt.code =
1118 MEDIA_BUS_FMT_SBGGR10_1X10;
1119 asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE_VF].fmt.code =
1120 MEDIA_BUS_FMT_SBGGR10_1X10;
1121 asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE].fmt.code =
1122 MEDIA_BUS_FMT_SBGGR10_1X10;
1123 asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE_VIDEO].fmt.code =
1124 MEDIA_BUS_FMT_SBGGR10_1X10;
1126 me->ops = &isp_subdev_media_ops;
1127 me->function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
1128 ret = media_entity_pads_init(me, ATOMISP_SUBDEV_PADS_NUM, pads);
1132 atomisp_init_subdev_pipe(asd, &asd->video_in,
1133 V4L2_BUF_TYPE_VIDEO_OUTPUT);
1135 atomisp_init_subdev_pipe(asd, &asd->video_out_preview,
1136 V4L2_BUF_TYPE_VIDEO_CAPTURE);
1138 atomisp_init_subdev_pipe(asd, &asd->video_out_vf,
1139 V4L2_BUF_TYPE_VIDEO_CAPTURE);
1141 atomisp_init_subdev_pipe(asd, &asd->video_out_capture,
1142 V4L2_BUF_TYPE_VIDEO_CAPTURE);
1144 atomisp_init_subdev_pipe(asd, &asd->video_out_video_capture,
1145 V4L2_BUF_TYPE_VIDEO_CAPTURE);
1147 atomisp_init_acc_pipe(asd, &asd->video_acc);
1149 ret = atomisp_video_init(&asd->video_in, "MEMORY",
1150 ATOMISP_RUN_MODE_SDV);
1154 ret = atomisp_video_init(&asd->video_out_capture, "CAPTURE",
1155 ATOMISP_RUN_MODE_STILL_CAPTURE);
1159 ret = atomisp_video_init(&asd->video_out_vf, "VIEWFINDER",
1160 ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE);
1164 ret = atomisp_video_init(&asd->video_out_preview, "PREVIEW",
1165 ATOMISP_RUN_MODE_PREVIEW);
1169 ret = atomisp_video_init(&asd->video_out_video_capture, "VIDEO",
1170 ATOMISP_RUN_MODE_VIDEO);
1174 atomisp_acc_init(&asd->video_acc, "ACC");
1176 ret = v4l2_ctrl_handler_init(&asd->ctrl_handler, 1);
1180 asd->fmt_auto = v4l2_ctrl_new_custom(&asd->ctrl_handler,
1181 &ctrl_fmt_auto, NULL);
1182 asd->run_mode = v4l2_ctrl_new_custom(&asd->ctrl_handler,
1183 &ctrl_run_mode, NULL);
1184 asd->vfpp = v4l2_ctrl_new_custom(&asd->ctrl_handler,
1186 asd->continuous_mode = v4l2_ctrl_new_custom(&asd->ctrl_handler,
1187 &ctrl_continuous_mode, NULL);
1188 asd->continuous_viewfinder = v4l2_ctrl_new_custom(&asd->ctrl_handler,
1189 &ctrl_continuous_viewfinder,
1191 asd->continuous_raw_buffer_size =
1192 v4l2_ctrl_new_custom(&asd->ctrl_handler,
1193 &ctrl_continuous_raw_buffer_size,
1196 asd->enable_raw_buffer_lock =
1197 v4l2_ctrl_new_custom(&asd->ctrl_handler,
1198 &ctrl_enable_raw_buffer_lock,
1201 v4l2_ctrl_new_custom(&asd->ctrl_handler,
1205 v4l2_ctrl_new_custom(&asd->ctrl_handler,
1209 /* Make controls visible on subdev as well. */
1210 asd->subdev.ctrl_handler = &asd->ctrl_handler;
1211 spin_lock_init(&asd->raw_buffer_bitmap_lock);
1212 return asd->ctrl_handler.error;
1215 int atomisp_create_pads_links(struct atomisp_device *isp)
1217 struct atomisp_sub_device *asd;
1220 isp->num_of_streams = 2;
1221 for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) {
1222 for (j = 0; j < isp->num_of_streams; j++) {
1224 media_create_pad_link(&isp->csi2_port[i].subdev.
1225 entity, CSI2_PAD_SOURCE,
1226 &isp->asd[j].subdev.entity,
1227 ATOMISP_SUBDEV_PAD_SINK, 0);
1232 for (i = 0; i < isp->input_cnt - 2; i++) {
1233 ret = media_create_pad_link(&isp->inputs[i].camera->entity, 0,
1234 &isp->csi2_port[isp->inputs[i].
1235 port].subdev.entity,
1237 MEDIA_LNK_FL_ENABLED |
1238 MEDIA_LNK_FL_IMMUTABLE);
1242 for (i = 0; i < isp->num_of_streams; i++) {
1244 ret = media_create_pad_link(&asd->subdev.entity,
1245 ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW,
1246 &asd->video_out_preview.vdev.entity,
1250 ret = media_create_pad_link(&asd->subdev.entity,
1251 ATOMISP_SUBDEV_PAD_SOURCE_VF,
1252 &asd->video_out_vf.vdev.entity, 0,
1256 ret = media_create_pad_link(&asd->subdev.entity,
1257 ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE,
1258 &asd->video_out_capture.vdev.entity,
1262 ret = media_create_pad_link(&asd->subdev.entity,
1263 ATOMISP_SUBDEV_PAD_SOURCE_VIDEO,
1264 &asd->video_out_video_capture.vdev.
1269 * file input only supported on subdev0
1270 * so do not create pad link for subdevs other then subdev0
1274 ret = media_create_pad_link(&asd->video_in.vdev.entity,
1275 0, &asd->subdev.entity,
1276 ATOMISP_SUBDEV_PAD_SINK, 0);
1283 static void atomisp_subdev_cleanup_entities(struct atomisp_sub_device *asd)
1285 v4l2_ctrl_handler_free(&asd->ctrl_handler);
1287 media_entity_cleanup(&asd->subdev.entity);
1290 void atomisp_subdev_cleanup_pending_events(struct atomisp_sub_device *asd)
1292 struct v4l2_fh *fh, *fh_tmp;
1293 struct v4l2_event event;
1294 unsigned int i, pending_event;
1296 list_for_each_entry_safe(fh, fh_tmp,
1297 &asd->subdev.devnode->fh_list, list) {
1298 pending_event = v4l2_event_pending(fh);
1299 for (i = 0; i < pending_event; i++)
1300 v4l2_event_dequeue(fh, &event, 1);
1304 void atomisp_subdev_unregister_entities(struct atomisp_sub_device *asd)
1306 atomisp_subdev_cleanup_entities(asd);
1307 v4l2_device_unregister_subdev(&asd->subdev);
1308 atomisp_video_unregister(&asd->video_in);
1309 atomisp_video_unregister(&asd->video_out_preview);
1310 atomisp_video_unregister(&asd->video_out_vf);
1311 atomisp_video_unregister(&asd->video_out_capture);
1312 atomisp_video_unregister(&asd->video_out_video_capture);
1313 atomisp_acc_unregister(&asd->video_acc);
1316 int atomisp_subdev_register_entities(struct atomisp_sub_device *asd,
1317 struct v4l2_device *vdev)
1323 * FIXME: check if all device caps are properly initialized.
1324 * Should any of those use V4L2_CAP_META_OUTPUT? Probably yes.
1327 device_caps = V4L2_CAP_VIDEO_CAPTURE |
1330 /* Register the subdev and video node. */
1332 ret = v4l2_device_register_subdev(vdev, &asd->subdev);
1336 asd->video_out_preview.vdev.v4l2_dev = vdev;
1337 asd->video_out_preview.vdev.device_caps = device_caps |
1338 V4L2_CAP_VIDEO_OUTPUT;
1339 ret = video_register_device(&asd->video_out_preview.vdev,
1340 VFL_TYPE_VIDEO, -1);
1344 asd->video_out_capture.vdev.v4l2_dev = vdev;
1345 asd->video_out_capture.vdev.device_caps = device_caps |
1346 V4L2_CAP_VIDEO_OUTPUT;
1347 ret = video_register_device(&asd->video_out_capture.vdev,
1348 VFL_TYPE_VIDEO, -1);
1352 asd->video_out_vf.vdev.v4l2_dev = vdev;
1353 asd->video_out_vf.vdev.device_caps = device_caps |
1354 V4L2_CAP_VIDEO_OUTPUT;
1355 ret = video_register_device(&asd->video_out_vf.vdev,
1356 VFL_TYPE_VIDEO, -1);
1360 asd->video_out_video_capture.vdev.v4l2_dev = vdev;
1361 asd->video_out_video_capture.vdev.device_caps = device_caps |
1362 V4L2_CAP_VIDEO_OUTPUT;
1363 ret = video_register_device(&asd->video_out_video_capture.vdev,
1364 VFL_TYPE_VIDEO, -1);
1367 asd->video_acc.vdev.v4l2_dev = vdev;
1368 asd->video_acc.vdev.device_caps = device_caps |
1369 V4L2_CAP_VIDEO_OUTPUT;
1370 ret = video_register_device(&asd->video_acc.vdev,
1371 VFL_TYPE_VIDEO, -1);
1376 * file input only supported on subdev0
1377 * so do not create video node for subdevs other then subdev0
1382 asd->video_in.vdev.v4l2_dev = vdev;
1383 asd->video_in.vdev.device_caps = device_caps |
1384 V4L2_CAP_VIDEO_CAPTURE;
1385 ret = video_register_device(&asd->video_in.vdev,
1386 VFL_TYPE_VIDEO, -1);
1393 atomisp_subdev_unregister_entities(asd);
1398 * atomisp_subdev_init - ISP Subdevice initialization.
1399 * @dev: Device pointer specific to the ATOM ISP.
1401 * TODO: Get the initialisation values from platform data.
1403 * Return 0 on success or a negative error code otherwise.
1405 int atomisp_subdev_init(struct atomisp_device *isp)
1407 struct atomisp_sub_device *asd;
1411 * CSS2.0 running ISP2400 support
1414 isp->num_of_streams = 2;
1415 isp->asd = devm_kzalloc(isp->dev, sizeof(struct atomisp_sub_device) *
1416 isp->num_of_streams, GFP_KERNEL);
1419 for (i = 0; i < isp->num_of_streams; i++) {
1421 spin_lock_init(&asd->lock);
1423 isp_subdev_init_params(asd);
1425 ret = isp_subdev_init_entities(asd);
1427 atomisp_subdev_cleanup_entities(asd);