Lines Matching defs:isp

96 	struct atomisp_device *isp = asd->isp;
101 ret = v4l2_subdev_call_state_active(isp->inputs[asd->input_curr].camera,
121 static int write_target_freq_to_hw(struct atomisp_device *isp,
128 if (!isp->hpll_freq) {
129 dev_err(isp->dev, "failed to get hpll_freq. no change to freq\n");
135 dev_dbg(isp->dev, "clearing ISPSSPM1 valid bit.\n");
140 ratio = (2 * isp->hpll_freq + new_freq / 2) / new_freq - 1;
141 guar_ratio = (2 * isp->hpll_freq + 200 / 2) / 200 - 1;
157 dev_dbg(isp->dev, "waiting for ISPSSPM1 valid bit to be 0.\n");
167 dev_err(isp->dev, "DFS failed due to HW error.\n");
175 dev_dbg(isp->dev, "waiting for ISPSSPM1 status bit to be 0x%x.\n",
181 dev_err(isp->dev, "DFS target freq is rejected by HW.\n");
188 int atomisp_freq_scaling(struct atomisp_device *isp,
198 dfs = isp->dfs;
203 dev_err(isp->dev, "DFS configuration is invalid.\n");
217 fps = atomisp_get_sensor_fps(&isp->asd);
219 dev_info(isp->dev,
225 curr_rules.width = isp->asd.fmt[ATOMISP_SUBDEV_PAD_SOURCE].fmt.width;
226 curr_rules.height = isp->asd.fmt[ATOMISP_SUBDEV_PAD_SOURCE].fmt.height;
228 curr_rules.run_mode = isp->asd.run_mode->val;
253 dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);
255 if ((new_freq == isp->running_freq) && !force)
258 dev_dbg(isp->dev, "Programming DFS frequency to %d\n", new_freq);
260 ret = write_target_freq_to_hw(isp, new_freq);
262 isp->running_freq = new_freq;
271 int atomisp_reset(struct atomisp_device *isp)
276 dev_dbg(isp->dev, "%s\n", __func__);
278 ret = atomisp_power_off(isp->dev);
280 dev_err(isp->dev, "atomisp_power_off failed, %d\n", ret);
282 ret = atomisp_power_on(isp->dev);
284 dev_err(isp->dev, "atomisp_power_on failed, %d\n", ret);
285 isp->isp_fatal_error = true;
312 void atomisp_msi_irq_init(struct atomisp_device *isp)
314 struct pci_dev *pdev = to_pci_dev(isp->dev);
331 void atomisp_msi_irq_uninit(struct atomisp_device *isp)
333 struct pci_dev *pdev = to_pci_dev(isp->dev);
401 struct atomisp_device *isp)
407 dev_err(isp->dev, "CSI Receiver port %d errors:\n", port);
409 dev_err(isp->dev, " buffer overrun");
411 dev_err(isp->dev, " start-of-transmission error");
413 dev_err(isp->dev, " start-of-transmission sync error");
415 dev_err(isp->dev, " control error");
417 dev_err(isp->dev, " 2 or more ECC errors");
419 dev_err(isp->dev, " CRC mismatch");
421 dev_err(isp->dev, " unknown error");
423 dev_err(isp->dev, " frame sync error");
425 dev_err(isp->dev, " frame data error");
427 dev_err(isp->dev, " data timeout");
429 dev_err(isp->dev, " unknown escape command entry");
431 dev_err(isp->dev, " line sync error");
435 static void clear_irq_reg(struct atomisp_device *isp)
437 struct pci_dev *pdev = to_pci_dev(isp->dev);
448 struct atomisp_device *isp = (struct atomisp_device *)dev;
454 spin_lock_irqsave(&isp->lock, flags);
456 if (!isp->css_initialized) {
457 spin_unlock_irqrestore(&isp->lock, flags);
460 err = atomisp_css_irq_translate(isp, &irq_infos);
462 spin_unlock_irqrestore(&isp->lock, flags);
466 clear_irq_reg(isp);
468 if (!isp->asd.streaming)
472 atomic_inc(&isp->asd.sof_count);
473 atomisp_sof_event(&isp->asd);
483 if (atomic_read(&isp->asd.sequence) == atomic_read(&isp->asd.sequence_temp))
484 atomic_set(&isp->asd.sequence_temp, atomic_read(&isp->asd.sof_count));
486 dev_dbg_ratelimited(isp->dev, "irq:0x%x (SOF)\n", irq_infos);
491 atomic_set(&isp->asd.sequence, atomic_read(&isp->asd.sequence_temp));
501 print_csi_rx_errors(port, isp);
509 atomisp_eof_event(&isp->asd, eof_event.event.exp_id);
510 dev_dbg_ratelimited(isp->dev, "ISYS event: EOF exp_id %d\n",
519 spin_unlock_irqrestore(&isp->lock, flags);
521 dev_dbg_ratelimited(isp->dev, "irq:0x%x (unhandled)\n", irq_infos);
526 spin_unlock_irqrestore(&isp->lock, flags);
529 dev_dbg_ratelimited(isp->dev, "irq:0x%x (ignored, as not streaming anymore)\n",
549 void dump_sp_dmem(struct atomisp_device *isp, unsigned int addr,
555 dev_dbg(isp->dev, "atomisp mmio base: %p\n", isp->base);
556 dev_dbg(isp->dev, "%s, addr:0x%x, size: %d, size32: %d\n", __func__,
559 dev_err(isp->dev, "illegal size (%d) or addr (0x%x)\n",
566 data = readl(isp->base + addr);
567 dev_dbg(isp->dev, "%s, \t [0x%x]:0x%x\n", __func__, addr, data);
613 dev_warn(pipe->isp->dev, "Warning: CSS frames queued on flush\n");
671 struct atomisp_device *isp = asd->isp;
674 lockdep_assert_held(&isp->mutex);
685 dev_err(isp->dev, "%s, unsupported buffer type: %d\n",
695 dev_err(isp->dev,
717 dev_dbg(isp->dev, "%s: s3a stat with exp_id %d is ready\n",
720 dev_dbg(isp->dev, "%s: s3a stat is ready with no exp_id found\n",
742 dev_dbg(isp->dev, "%s: metadata with exp_id %d is ready\n",
745 dev_dbg(isp->dev, "%s: metadata is ready with no exp_id found\n",
766 dev_dbg(isp->dev, "%s: dis stat with exp_id %d is ready\n",
769 dev_dbg(isp->dev, "%s: dis stat is ready with no exp_id found\n",
784 dev_dbg(isp->dev, "%s: vf frame with exp_id %d is ready\n",
801 dev_dbg(isp->dev, "%s: main frame with exp_id %d is ready\n",
867 dev_err(isp->dev, "%s, q to css fails: %d\n",
877 struct atomisp_device *isp = container_of(work, struct atomisp_device,
879 struct pci_dev *pdev = to_pci_dev(isp->dev);
883 mutex_lock(&isp->mutex);
885 if (!isp->asd.streaming)
888 atomisp_css_irq_enable(isp, IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF, false);
890 spin_lock_irqsave(&isp->lock, flags);
891 isp->asd.streaming = false;
892 spin_unlock_irqrestore(&isp->lock, flags);
895 ret = v4l2_subdev_call(isp->inputs[isp->asd.input_curr].camera, video, s_stream, 0);
897 dev_warn(isp->dev, "Stopping sensor stream failed: %d\n", ret);
899 atomisp_clear_css_buffer_counters(&isp->asd);
901 atomisp_css_stop(&isp->asd, true);
903 isp->asd.preview_exp_id = 1;
904 isp->asd.postview_exp_id = 1;
906 dev_dbg(isp->dev, "send reset event to %s\n", isp->asd.subdev.devnode->name);
907 atomisp_reset_event(&isp->asd);
915 isp->saved_regs.i_control | MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
918 atomisp_reset(isp);
920 atomisp_css_input_set_mode(&isp->asd, IA_CSS_INPUT_MODE_BUFFERED_SENSOR);
923 atomisp_create_pipes_stream(&isp->asd);
928 if (atomisp_css_start(&isp->asd)) {
929 dev_warn(isp->dev, "start SP failed, so do not set streaming to be enable!\n");
931 spin_lock_irqsave(&isp->lock, flags);
932 isp->asd.streaming = true;
933 spin_unlock_irqrestore(&isp->lock, flags);
936 atomisp_csi2_configure(&isp->asd);
938 atomisp_css_irq_enable(isp, IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF,
939 atomisp_css_valid_sof(isp));
941 if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_AUTO, true) < 0)
942 dev_dbg(isp->dev, "DFS auto failed while recovering!\n");
945 atomisp_flush_video_pipe(&isp->asd.video_out, VB2_BUF_STATE_ERROR, false);
948 atomisp_recover_params_queue(&isp->asd.video_out);
950 ret = v4l2_subdev_call(isp->inputs[isp->asd.input_curr].camera, video, s_stream, 1);
952 dev_err(isp->dev, "Starting sensor stream failed: %d\n", ret);
955 mutex_unlock(&isp->mutex);
960 struct atomisp_device *isp = isp_ptr;
964 spin_lock_irqsave(&isp->lock, flags);
965 streaming = isp->asd.streaming;
966 spin_unlock_irqrestore(&isp->lock, flags);
996 mutex_lock(&isp->mutex);
997 atomisp_css_isr_thread(isp);
998 mutex_unlock(&isp->mutex);
1224 /* Set nr config to isp parameters */
1245 /* Set tnr config to isp parameters */
1266 /* Set ob config to isp parameters */
1287 /* Set ee config to isp parameters */
1308 /* Set gamma table to isp parameters */
1328 /* Set ctc table to isp parameters */
1348 /* Set gamma correction params to isp parameters */
1369 /* Set narrow gamma flag to isp parameters */
1386 struct atomisp_device *isp = asd->isp;
1398 dev_err(isp->dev, "stat_buf allocate error\n");
1407 dev_err(isp->dev, "Failed to allocate memory for 3A statistics\n");
1413 dev_err(isp->dev,
1419 dev_err(isp->dev, "Failed to allocate memory for metadata\n");
1454 struct atomisp_device *isp = asd->isp;
1470 dev_err(isp->dev,
1478 dev_err(isp->dev,
1498 dev_err(isp->dev, "out of memory\n");
1508 dev_err(isp->dev,
1519 dev_err(isp->dev,
1601 dev_dbg(asd->isp->dev, ">%s start\n", __func__);
1603 dev_err(asd->isp->dev, "Set sensor array size is not valid\n");
1623 dev_warn(asd->isp->dev, "stream is not created");
1663 dev_dbg(asd->isp->dev,
1681 * Function to set/get 3A stat from isp
1686 struct atomisp_device *isp = asd->isp;
1705 dev_err(isp->dev, "3a statistics is not valid.\n");
1724 dev_err(isp->dev, "copy to user failed: copied %lu bytes\n",
1732 dev_dbg(isp->dev, "%s: finish getting exp_id %d 3a stat, isp_config_id %d\n",
1759 dev_err(asd->isp->dev, "%s the set pipe no support crop region"
1769 dev_err(asd->isp->dev, "%s err effective resolution"
1812 dev_err(asd->isp->dev, "%s err current pipe output resolution"
1820 dev_err(asd->isp->dev, "%s err current pipe output resolution"
1871 dev_dbg(asd->isp->dev,
1920 dev_err(asd->isp->dev,
2095 dev_err(asd->isp->dev, "crop region error!");
2366 dev_err(asd->isp->dev, "copy shading table failed!");
2389 dev_err(asd->isp->dev, "shading table validate failed");
2397 dev_err(asd->isp->dev, "shading table w/h validate failed!");
2473 dev_err(asd->isp->dev, "dvs grid mismatch!\n");
2523 dev_err(asd->isp->dev, "copy dvs2 coef failed");
2529 dev_err(asd->isp->dev, "dvs grid mismatch!\n");
2596 dev_err(asd->isp->dev, "%s: internal error!", __func__);
2619 dev_err(asd->isp->dev, "copy morph table failed!");
2758 dev_err(asd->isp->dev, "copy morph table failed!");
2894 lockdep_assert_held(&asd->isp->mutex);
2955 lockdep_assert_held(&asd->isp->mutex);
2958 dev_err(asd->isp->dev, "%s: internal error!\n", __func__);
2962 dev_dbg(asd->isp->dev, "set parameter(per_frame_setting %d) isp_config_id %d of %s\n",
2974 dev_err(asd->isp->dev, "%s: failed to alloc params buffer\n",
3023 * Function to set/get isp parameters to isp
3128 struct atomisp_device *isp = asd->isp;
3138 v4l2_s_ctrl(NULL, isp->inputs[asd->input_curr].camera->ctrl_handler,
3236 /* Set bad pixel to isp parameters */
3399 /* Set nr config to isp parameters */
3422 /* Set false color to isp parameters */
3443 /* Set white balance to isp parameters */
3456 struct atomisp_device *isp = asd->isp;
3458 dev_dbg(isp->dev, ">%s %d\n", __func__, flag);
3465 /* Set white balance to isp parameters */
3472 dev_dbg(isp->dev, "<%s %d\n", __func__, flag);
3483 struct atomisp_device *isp = asd->isp;
3497 dev_dbg(isp->dev, "%s, zoom: %d\n", __func__, zoom);
3572 void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height,
3575 struct atomisp_input_subdev *input = &isp->inputs[isp->asd.input_curr];
3604 sink = atomisp_subdev_get_ffmt(&isp->asd.subdev, NULL, V4L2_SUBDEV_FORMAT_ACTIVE,
3609 dev_warn(isp->dev, "%s: Could not get sensor format\n", __func__);
3630 int atomisp_s_sensor_power(struct atomisp_device *isp, unsigned int input, bool on)
3634 if (isp->inputs[input].camera_on == on)
3637 ret = v4l2_subdev_call(isp->inputs[input].camera, core, s_power, on);
3639 dev_err(isp->dev, "Error setting sensor power %d: %d\n", on, ret);
3643 isp->inputs[input].camera_on = on;
3647 int atomisp_select_input(struct atomisp_device *isp, unsigned int input)
3649 unsigned int input_orig = isp->asd.input_curr;
3653 ret = atomisp_s_sensor_power(isp, input, 1);
3657 isp->asd.input_curr = input;
3661 atomisp_s_sensor_power(isp, input_orig, 0);
3663 atomisp_setup_input_links(isp);
3671 void atomisp_setup_input_links(struct atomisp_device *isp)
3675 lockdep_assert_held(&isp->media_dev.graph_mutex);
3679 &isp->csi2_port[i].subdev.entity.pads[CSI2_PAD_SOURCE],
3680 &isp->asd.subdev.entity.pads[ATOMISP_SUBDEV_PAD_SINK]);
3682 dev_err(isp->dev, "Error cannot find CSI2-port[%d] -> ISP link\n", i);
3691 if (isp->sensor_subdevs[i] == isp->inputs[isp->asd.input_curr].camera)
3700 static int atomisp_set_sensor_crop_and_fmt(struct atomisp_device *isp,
3704 struct atomisp_input_subdev *input = &isp->inputs[isp->asd.input_curr];
3727 ret = atomisp_s_sensor_power(isp, isp->asd.input_curr, 1);
3756 dev_err(isp->dev, "Error setting crop to %ux%u @%ux%u: %d\n",
3778 int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f,
3783 struct atomisp_sub_device *asd = &isp->asd;
3807 atomisp_get_padding(isp, f->width, f->height, &padding_w, &padding_h);
3812 dev_dbg(isp->dev, "try_mbus_fmt: try %ux%u\n", ffmt.width, ffmt.height);
3814 ret = atomisp_set_sensor_crop_and_fmt(isp, &ffmt, V4L2_SUBDEV_FORMAT_TRY);
3818 dev_dbg(isp->dev, "try_mbus_fmt: got %ux%u\n", ffmt.width, ffmt.height);
3822 dev_err(isp->dev, "unknown sensor format 0x%8.8x\n",
3840 /* app vs isp */
3858 enum mipi_port_id atomisp_port_to_mipi_port(struct atomisp_device *isp,
3869 dev_err(isp->dev, "unsupported port: %d\n", port);
3880 struct atomisp_device *isp = asd->isp;
3881 struct atomisp_input_subdev *input = &isp->inputs[asd->input_curr];
3947 mipi_port = atomisp_port_to_mipi_port(isp, input->port);
3949 isp->sensor_lanes[mipi_port],
3989 dev_dbg(asd->isp->dev, "css_input_resolution_changed to %ux%u\n",
4023 struct atomisp_device *isp = video_get_drvdata(vdev);
4025 struct atomisp_input_subdev *input = &isp->inputs[asd->input_curr];
4140 dev_err(isp->dev,
4158 dev_err(isp->dev, "configure_output %ux%u, format %8.8x\n",
4165 dev_err(isp->dev, "configure_pp_input %ux%u\n",
4177 dev_err(isp->dev, "__get_frame_info %ux%u (padded to %u) returned %d\n",
4226 dev_dbg(asd->isp->dev, "copy_mode: %d\n", asd->copy_mode);
4234 struct atomisp_device *isp = asd->isp;
4249 dev_dbg(isp->dev, "s_mbus_fmt: ask %ux%u (padding %ux%u, dvs %ux%u)\n",
4259 ret = atomisp_set_sensor_crop_and_fmt(isp, &ffmt, V4L2_SUBDEV_FORMAT_TRY);
4263 dev_dbg(isp->dev, "video dis: sensor width: %d, height: %d\n",
4271 dev_warn(isp->dev,
4277 ret = atomisp_set_sensor_crop_and_fmt(isp, &ffmt, V4L2_SUBDEV_FORMAT_ACTIVE);
4283 dev_dbg(isp->dev, "sensor width: %d, height: %d\n",
4292 dev_warn(isp->dev,
4306 struct atomisp_device *isp = video_get_drvdata(vdev);
4321 dev_dbg(isp->dev,
4326 ret = atomisp_try_fmt(isp, &f->fmt.pix, &format_bridge, &snr_format_bridge);
4344 atomisp_get_padding(isp, f->fmt.pix.width, f->fmt.pix.height,
4356 dev_warn(isp->dev,
4361 atomisp_csi_lane_config(isp);
4409 dev_warn(isp->dev, "Can't set format on ISP. Error %d\n", ret);
4417 dev_dbg(isp->dev, "%s: %dx%d, image size: %d, %d bytes per line\n",
4489 struct atomisp_device *isp = asd->isp;
4492 dev_warn(isp->dev, "%s Raw Buffer Lock is disable.\n", __func__);
4496 dev_err(isp->dev, "%s streaming %d invalid exp_id %d.\n",
4501 dev_err(isp->dev, "%s exp_id %d invalid.\n", __func__, exp_id);
4549 dev_dbg(asd->isp->dev, "%s: exp_id %d, raw_buffer_locked_count %d\n",
4556 struct atomisp_device *isp = asd->isp;
4560 lockdep_assert_held(&isp->mutex);
4564 dev_err(isp->dev, "%s exp_id %d invalid %d.\n", __func__, value, ret);
4568 dev_dbg(isp->dev, "%s exp_id %d\n", __func__, value);
4571 dev_err(isp->dev, "%s exp_id %d failed.\n", __func__, value);
4579 struct atomisp_device *isp = asd->isp;
4583 lockdep_assert_held(&isp->mutex);
4587 dev_err(isp->dev, "%s exp_id %d invalid %d.\n", __func__, value, ret);
4591 dev_dbg(isp->dev, "%s exp_id %d\n", __func__, value);
4594 dev_err(isp->dev, "%s exp_id %d failed, err %d.\n",
4620 lockdep_assert_held(&asd->isp->mutex);
4622 dev_dbg(asd->isp->dev, "%s: trying to inject a fake event 0x%x\n",